<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP, BangPatterns #-}</span><span>
</span><span id="line-2"></span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}</span><span>
</span><span id="line-4"></span><span>
</span><span id="line-5"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-6"></span><span class="hs-comment">--</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Stg to C-- code generation: expressions</span><span>
</span><span id="line-8"></span><span class="hs-comment">--</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- (c) The University of Glasgow 2004-2006</span><span>
</span><span id="line-10"></span><span class="hs-comment">--</span><span>
</span><span id="line-11"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-12"></span><span>
</span><span id="line-13"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.StgToCmm.Expr</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier">cgExpr</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-17"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator">(&lt;*&gt;)</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="hs-pragma">{-# SOURCE</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Bind.html"><span class="hs-identifier">GHC.StgToCmm.Bind</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Bind.html#cgBind"><span class="hs-identifier">cgBind</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html"><span class="hs-identifier">GHC.StgToCmm.Monad</span></a></span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Heap.html"><span class="hs-identifier">GHC.StgToCmm.Heap</span></a></span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Env.html"><span class="hs-identifier">GHC.StgToCmm.Env</span></a></span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.DataCon.html"><span class="hs-identifier">GHC.StgToCmm.DataCon</span></a></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Prof.html"><span class="hs-identifier">GHC.StgToCmm.Prof</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.StgToCmm.Prof.html#saveCurrentCostCentre"><span class="hs-identifier">saveCurrentCostCentre</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Prof.html#restoreCurrentCostCentre"><span class="hs-identifier">restoreCurrentCostCentre</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Prof.html#emitSetCCC"><span class="hs-identifier">emitSetCCC</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Layout.html"><span class="hs-identifier">GHC.StgToCmm.Layout</span></a></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Prim.html"><span class="hs-identifier">GHC.StgToCmm.Prim</span></a></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Hpc.html"><span class="hs-identifier">GHC.StgToCmm.Hpc</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Ticky.html"><span class="hs-identifier">GHC.StgToCmm.Ticky</span></a></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Utils.html"><span class="hs-identifier">GHC.StgToCmm.Utils</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Closure.html"><span class="hs-identifier">GHC.StgToCmm.Closure</span></a></span><span>
</span><span id="line-32"></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html"><span class="hs-identifier">GHC.Stg.Syntax</span></a></span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Graph.html"><span class="hs-identifier">GHC.Cmm.Graph</span></a></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html"><span class="hs-identifier">GHC.Cmm.BlockId</span></a></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.html"><span class="hs-identifier">GHC.Cmm</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#succ"><span class="hs-identifier">succ</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Info.html"><span class="hs-identifier">GHC.Cmm.Info</span></a></span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html"><span class="hs-identifier">GHC.Core.DataCon</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#mAX_PTR_TAG"><span class="hs-identifier">mAX_PTR_TAG</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html"><span class="hs-identifier">GHC.Types.ForeignCall</span></a></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.PrimOps.html"><span class="hs-identifier">GHC.Builtin.PrimOps</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>        </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Type.html#isUnliftedType"><span class="hs-identifier">isUnliftedType</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.RepType.html"><span class="hs-identifier">GHC.Types.RepType</span></a></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.RepType.html#isVoidTy"><span class="hs-identifier">isVoidTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.RepType.html#countConRepArgs"><span class="hs-identifier">countConRepArgs</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.CostCentre.html"><span class="hs-identifier">GHC.Types.CostCentre</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.CostCentre.html#CostCentreStack"><span class="hs-identifier">CostCentreStack</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.CostCentre.html#currentCCS"><span class="hs-identifier">currentCCS</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html"><span class="hs-identifier">GHC.Data.FastString</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-53"></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier">unless</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.html#void"><span class="hs-identifier">void</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Arrow.html#"><span class="hs-identifier">Control.Arrow</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Control.Arrow.html#first"><span class="hs-identifier">first</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>     </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#partition"><span class="hs-identifier">partition</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-59"></span><span class="hs-comment">--              cgExpr: the main function</span><span>
</span><span id="line-60"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-61"></span><span>
</span><span id="line-62"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-type">cgExpr</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#CgStgExpr"><span class="hs-identifier hs-type">CgStgExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#ReturnKind"><span class="hs-identifier hs-type">ReturnKind</span></a></span><span>
</span><span id="line-63"></span><span>
</span><span id="line-64"></span><span id="cgExpr"><span class="annot"><span class="annottext">cgExpr :: CgStgExpr -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var hs-var">cgExpr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgApp"><span class="hs-identifier hs-type">StgApp</span></a></span><span> </span><span id="local-6989586621681062125"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681062125"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span id="local-6989586621681062124"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681062124"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; [StgArg] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgIdApp"><span class="hs-identifier hs-var">cgIdApp</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681062125"><span class="hs-identifier hs-var">fun</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681062124"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-65"></span><span>
</span><span id="line-66"></span><span class="hs-comment">-- seq# a s ==&gt; a</span><span>
</span><span id="line-67"></span><span class="hs-comment">-- See Note [seq# magic] in GHC.Core.Opt.ConstantFold</span><span>
</span><span id="line-68"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgOpApp"><span class="hs-identifier hs-type">StgOpApp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgPrimOp"><span class="hs-identifier hs-type">StgPrimOp</span></a></span><span> </span><span class="annot"><span class="annottext">PrimOp
</span><a href="GHC.Builtin.PrimOps.html#SeqOp"><span class="hs-identifier hs-var">SeqOp</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgVarArg"><span class="hs-identifier hs-type">StgVarArg</span></a></span><span> </span><span id="local-6989586621681062118"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681062118"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">StgArg
</span><span class="hs-identifier">_</span></span><span class="hs-special">]</span><span> </span><span id="local-6989586621681062117"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681062117"><span class="hs-identifier hs-var">_res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-69"></span><span>  </span><span class="annot"><span class="annottext">Id -&gt; [StgArg] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgIdApp"><span class="hs-identifier hs-var">cgIdApp</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681062118"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-70"></span><span>
</span><span id="line-71"></span><span class="hs-comment">-- dataToTag# :: a -&gt; Int#</span><span>
</span><span id="line-72"></span><span class="hs-comment">-- See Note [dataToTag#] in primops.txt.pp</span><span>
</span><span id="line-73"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgOpApp"><span class="hs-identifier hs-type">StgOpApp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgPrimOp"><span class="hs-identifier hs-type">StgPrimOp</span></a></span><span> </span><span class="annot"><span class="annottext">PrimOp
</span><a href="GHC.Builtin.PrimOps.html#DataToTagOp"><span class="hs-identifier hs-var">DataToTagOp</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgVarArg"><span class="hs-identifier hs-type">StgVarArg</span></a></span><span> </span><span id="local-6989586621681062115"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681062115"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">]</span><span> </span><span id="local-6989586621681062114"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681062114"><span class="hs-identifier hs-var">_res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-74"></span><span>  </span><span id="local-6989586621681062113"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681062113"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-75"></span><span>  </span><span id="local-6989586621681062111"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681062111"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-76"></span><span>  </span><span class="annot"><span class="annottext">FastString -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitComment"><span class="hs-identifier hs-var">emitComment</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#mkFastString"><span class="hs-identifier hs-var">mkFastString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dataToTag#&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-77"></span><span>  </span><span id="local-6989586621681062107"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681062107"><span class="hs-identifier hs-var">tmp</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; FCode LocalReg
forall (m :: * -&gt; *). MonadUnique m =&gt; CmmType -&gt; m LocalReg
</span><a href="GHC.StgToCmm.Utils.html#newTemp"><span class="hs-identifier hs-var">newTemp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.Cmm.Type.html#bWord"><span class="hs-identifier hs-var">bWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681062111"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-78"></span><span>  </span><span class="annot"><span class="annottext">ReturnKind
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Sequel -&gt; FCode ReturnKind -&gt; FCode ReturnKind
forall a. Sequel -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Monad.html#withSequel"><span class="hs-identifier hs-var">withSequel</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[LocalReg] -&gt; Bool -&gt; Sequel
</span><a href="GHC.StgToCmm.Monad.html#AssignTo"><span class="hs-identifier hs-var">AssignTo</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681062107"><span class="hs-identifier hs-var">tmp</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; [StgArg] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgIdApp"><span class="hs-identifier hs-var">cgIdApp</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681062115"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-79"></span><span>  </span><span class="hs-comment">-- TODO: For small types look at the tag bits instead of reading info table</span><span>
</span><span id="line-80"></span><span>  </span><span class="annot"><span class="annottext">[CmmExpr] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Layout.html#emitReturn"><span class="hs-identifier hs-var">emitReturn</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.Cmm.Info.html#getConstrTag"><span class="hs-identifier hs-var">getConstrTag</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681062113"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmUntag"><span class="hs-identifier hs-var">cmmUntag</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681062113"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681062107"><span class="hs-identifier hs-var">tmp</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-81"></span><span>
</span><span id="line-82"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgOpApp"><span class="hs-identifier hs-type">StgOpApp</span></a></span><span> </span><span id="local-6989586621681062097"><span class="annot"><span class="annottext">StgOp
</span><a href="#local-6989586621681062097"><span class="hs-identifier hs-var">op</span></a></span></span><span> </span><span id="local-6989586621681062096"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681062096"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span id="local-6989586621681062095"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681062095"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgOp -&gt; [StgArg] -&gt; Type -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Prim.html#cgOpApp"><span class="hs-identifier hs-var">cgOpApp</span></a></span><span> </span><span class="annot"><span class="annottext">StgOp
</span><a href="#local-6989586621681062097"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681062096"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681062095"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-83"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgConApp"><span class="hs-identifier hs-type">StgConApp</span></a></span><span> </span><span id="local-6989586621681062092"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681062092"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span id="local-6989586621681062091"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681062091"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; [StgArg] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgConApp"><span class="hs-identifier hs-var">cgConApp</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681062092"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681062091"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-84"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgTick"><span class="hs-identifier hs-type">StgTick</span></a></span><span> </span><span id="local-6989586621681062088"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621681062088"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621681062087"><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681062087"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tickish Id -&gt; FCode ()
</span><a href="GHC.StgToCmm.Expr.html#cgTick"><span class="hs-identifier hs-var">cgTick</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621681062088"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">FCode () -&gt; FCode ReturnKind -&gt; FCode ReturnKind
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CgStgExpr -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681062087"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-85"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgLit"><span class="hs-identifier hs-type">StgLit</span></a></span><span> </span><span id="local-6989586621681062084"><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621681062084"><span class="hs-identifier hs-var">lit</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681062083"><span class="annot"><span class="annottext">CmmLit
</span><a href="#local-6989586621681062083"><span class="hs-identifier hs-var">cmm_lit</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Literal -&gt; FCode CmmLit
</span><a href="GHC.StgToCmm.Utils.html#cgLit"><span class="hs-identifier hs-var">cgLit</span></a></span><span> </span><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621681062084"><span class="hs-identifier hs-var">lit</span></a></span><span>
</span><span id="line-86"></span><span>                               </span><span class="annot"><span class="annottext">[CmmExpr] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Layout.html#emitReturn"><span class="hs-identifier hs-var">emitReturn</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CmmLit -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-var">CmmLit</span></a></span><span> </span><span class="annot"><span class="annottext">CmmLit
</span><a href="#local-6989586621681062083"><span class="hs-identifier hs-var">cmm_lit</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgLet"><span class="hs-identifier hs-type">StgLet</span></a></span><span> </span><span class="annot"><span class="annottext">XLet 'CodeGen
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681062079"><span class="annot"><span class="annottext">GenStgBinding 'CodeGen
</span><a href="#local-6989586621681062079"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span id="local-6989586621681062078"><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681062078"><span class="hs-identifier hs-var">expr</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">GenStgBinding 'CodeGen -&gt; FCode ()
</span><a href="GHC.StgToCmm.Bind.html#cgBind"><span class="hs-identifier hs-var">cgBind</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgBinding 'CodeGen
</span><a href="#local-6989586621681062079"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">;</span><span>     </span><span class="annot"><span class="annottext">CgStgExpr -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681062078"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-89"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgLetNoEscape"><span class="hs-identifier hs-type">StgLetNoEscape</span></a></span><span> </span><span class="annot"><span class="annottext">XLetNoEscape 'CodeGen
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681062076"><span class="annot"><span class="annottext">GenStgBinding 'CodeGen
</span><a href="#local-6989586621681062076"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span id="local-6989586621681062075"><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681062075"><span class="hs-identifier hs-var">expr</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-90"></span><span>  </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681062074"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681062074"><span class="hs-identifier hs-var">u</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Unique
</span><a href="GHC.StgToCmm.Monad.html#newUnique"><span class="hs-identifier hs-var">newUnique</span></a></span><span>
</span><span id="line-91"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681062072"><span class="annot"><span class="annottext">join_id :: BlockId
</span><a href="#local-6989586621681062072"><span class="hs-identifier hs-var hs-var">join_id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unique -&gt; BlockId
</span><a href="GHC.Cmm.BlockId.html#mkBlockId"><span class="hs-identifier hs-var">mkBlockId</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681062074"><span class="hs-identifier hs-var">u</span></a></span><span>
</span><span id="line-92"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; GenStgBinding 'CodeGen -&gt; FCode ()
</span><a href="GHC.StgToCmm.Expr.html#cgLneBinds"><span class="hs-identifier hs-var">cgLneBinds</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681062072"><span class="hs-identifier hs-var">join_id</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgBinding 'CodeGen
</span><a href="#local-6989586621681062076"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-93"></span><span>     </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681062069"><span class="annot"><span class="annottext">ReturnKind
</span><a href="#local-6989586621681062069"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CgStgExpr -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681062075"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-94"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitLabel"><span class="hs-identifier hs-var">emitLabel</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681062072"><span class="hs-identifier hs-var">join_id</span></a></span><span>
</span><span id="line-95"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">ReturnKind -&gt; FCode ReturnKind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ReturnKind
</span><a href="#local-6989586621681062069"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-96"></span><span>
</span><span id="line-97"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgCase"><span class="hs-identifier hs-type">StgCase</span></a></span><span> </span><span id="local-6989586621681062066"><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681062066"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span id="local-6989586621681062065"><span class="annot"><span class="annottext">BinderP 'CodeGen
</span><a href="#local-6989586621681062065"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621681062064"><span class="annot"><span class="annottext">AltType
</span><a href="#local-6989586621681062064"><span class="hs-identifier hs-var">alt_type</span></a></span></span><span> </span><span id="local-6989586621681062063"><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681062063"><span class="hs-identifier hs-var">alts</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-98"></span><span>  </span><span class="annot"><span class="annottext">CgStgExpr
-&gt; Id -&gt; AltType -&gt; [GenStgAlt 'CodeGen] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgCase"><span class="hs-identifier hs-var">cgCase</span></a></span><span> </span><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681062066"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
BinderP 'CodeGen
</span><a href="#local-6989586621681062065"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">AltType
</span><a href="#local-6989586621681062064"><span class="hs-identifier hs-var">alt_type</span></a></span><span> </span><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681062063"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-99"></span><span>
</span><span id="line-100"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgLam"><span class="hs-identifier hs-type">StgLam</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; FCode ReturnKind
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cgExpr: StgLam&quot;</span></span><span>
</span><span id="line-101"></span><span>
</span><span id="line-102"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-103"></span><span class="hs-comment">--              Let no escape</span><span>
</span><span id="line-104"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-105"></span><span>
</span><span id="line-106"></span><span class="hs-comment">{- Generating code for a let-no-escape binding, aka join point is very
very similar to what we do for a case expression.  The duality is
between
        let-no-escape x = b
        in e
and
        case e of ... -&gt; b

That is, the RHS of 'x' (ie 'b') will execute *later*, just like
the alternative of the case; it needs to be compiled in an environment
in which all volatile bindings are forgotten, and the free vars are
bound only to stable things like stack locations..  The 'e' part will
execute *next*, just like the scrutinee of a case. -}</span><span>
</span><span id="line-119"></span><span>
</span><span id="line-120"></span><span class="hs-comment">-------------------------</span><span>
</span><span id="line-121"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgLneBinds"><span class="hs-identifier hs-type">cgLneBinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#CgStgBinding"><span class="hs-identifier hs-type">CgStgBinding</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-122"></span><span id="cgLneBinds"><span class="annot"><span class="annottext">cgLneBinds :: BlockId -&gt; GenStgBinding 'CodeGen -&gt; FCode ()
</span><a href="GHC.StgToCmm.Expr.html#cgLneBinds"><span class="hs-identifier hs-var hs-var">cgLneBinds</span></a></span></span><span> </span><span id="local-6989586621681062058"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681062058"><span class="hs-identifier hs-var">join_id</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgNonRec"><span class="hs-identifier hs-type">StgNonRec</span></a></span><span> </span><span id="local-6989586621681062056"><span class="annot"><span class="annottext">BinderP 'CodeGen
</span><a href="#local-6989586621681062056"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621681062055"><span class="annot"><span class="annottext">GenStgRhs 'CodeGen
</span><a href="#local-6989586621681062055"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-123"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681062054"><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681062054"><span class="hs-identifier hs-var">local_cc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode (Maybe LocalReg)
</span><a href="GHC.StgToCmm.Prof.html#saveCurrentCostCentre"><span class="hs-identifier hs-var">saveCurrentCostCentre</span></a></span><span>
</span><span id="line-124"></span><span>                </span><span class="hs-comment">-- See Note [Saving the current cost centre]</span><span>
</span><span id="line-125"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681062053"><span class="annot"><span class="annottext">CgIdInfo
</span><a href="#local-6989586621681062053"><span class="hs-identifier hs-var">info</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681062052"><span class="annot"><span class="annottext">FCode ()
</span><a href="#local-6989586621681062052"><span class="hs-identifier hs-var">fcode</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">BlockId
-&gt; Maybe LocalReg
-&gt; Id
-&gt; GenStgRhs 'CodeGen
-&gt; FCode (CgIdInfo, FCode ())
</span><a href="GHC.StgToCmm.Expr.html#cgLetNoEscapeRhs"><span class="hs-identifier hs-var">cgLetNoEscapeRhs</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681062058"><span class="hs-identifier hs-var">join_id</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681062054"><span class="hs-identifier hs-var">local_cc</span></a></span><span> </span><span class="annot"><span class="annottext">Id
BinderP 'CodeGen
</span><a href="#local-6989586621681062056"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgRhs 'CodeGen
</span><a href="#local-6989586621681062055"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-126"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">FCode ()
</span><a href="#local-6989586621681062052"><span class="hs-identifier hs-var">fcode</span></a></span><span>
</span><span id="line-127"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CgIdInfo -&gt; FCode ()
</span><a href="GHC.StgToCmm.Env.html#addBindC"><span class="hs-identifier hs-var">addBindC</span></a></span><span> </span><span class="annot"><span class="annottext">CgIdInfo
</span><a href="#local-6989586621681062053"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-128"></span><span>
</span><span id="line-129"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgLneBinds"><span class="hs-identifier hs-var">cgLneBinds</span></a></span><span> </span><span id="local-6989586621681062049"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681062049"><span class="hs-identifier hs-var">join_id</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgRec"><span class="hs-identifier hs-type">StgRec</span></a></span><span> </span><span id="local-6989586621681062047"><span class="annot"><span class="annottext">[(BinderP 'CodeGen, GenStgRhs 'CodeGen)]
</span><a href="#local-6989586621681062047"><span class="hs-identifier hs-var">pairs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-130"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681062046"><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681062046"><span class="hs-identifier hs-var">local_cc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode (Maybe LocalReg)
</span><a href="GHC.StgToCmm.Prof.html#saveCurrentCostCentre"><span class="hs-identifier hs-var">saveCurrentCostCentre</span></a></span><span>
</span><span id="line-131"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681062045"><span class="annot"><span class="annottext">[(CgIdInfo, FCode ())]
</span><a href="#local-6989586621681062045"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[FCode (CgIdInfo, FCode ())] -&gt; FCode [(CgIdInfo, FCode ())]
forall (t :: * -&gt; *) (m :: * -&gt; *) a.
(Traversable t, Monad m) =&gt;
t (m a) -&gt; m (t a)
</span><a href="../../base/src/Data.Traversable.html#sequence"><span class="hs-identifier hs-var">sequence</span></a></span><span> </span><span class="annot"><span class="annottext">([FCode (CgIdInfo, FCode ())] -&gt; FCode [(CgIdInfo, FCode ())])
-&gt; [FCode (CgIdInfo, FCode ())] -&gt; FCode [(CgIdInfo, FCode ())]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Id -&gt; GenStgRhs 'CodeGen -&gt; FCode (CgIdInfo, FCode ()))
-&gt; [(Id, GenStgRhs 'CodeGen)] -&gt; [FCode (CgIdInfo, FCode ())]
forall a b c. (a -&gt; b -&gt; c) -&gt; [(a, b)] -&gt; [c]
</span><a href="GHC.Utils.Misc.html#unzipWith"><span class="hs-identifier hs-var">unzipWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId
-&gt; Maybe LocalReg
-&gt; Id
-&gt; GenStgRhs 'CodeGen
-&gt; FCode (CgIdInfo, FCode ())
</span><a href="GHC.StgToCmm.Expr.html#cgLetNoEscapeRhs"><span class="hs-identifier hs-var">cgLetNoEscapeRhs</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681062049"><span class="hs-identifier hs-var">join_id</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681062046"><span class="hs-identifier hs-var">local_cc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Id, GenStgRhs 'CodeGen)]
[(BinderP 'CodeGen, GenStgRhs 'CodeGen)]
</span><a href="#local-6989586621681062047"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-132"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681062042"><span class="annot"><span class="annottext">[CgIdInfo]
</span><a href="#local-6989586621681062042"><span class="hs-identifier hs-var">infos</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681062041"><span class="annot"><span class="annottext">[FCode ()]
</span><a href="#local-6989586621681062041"><span class="hs-identifier hs-var">fcodes</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(CgIdInfo, FCode ())] -&gt; ([CgIdInfo], [FCode ()])
forall a b. [(a, b)] -&gt; ([a], [b])
</span><a href="../../base/src/GHC.List.html#unzip"><span class="hs-identifier hs-var">unzip</span></a></span><span> </span><span class="annot"><span class="annottext">[(CgIdInfo, FCode ())]
</span><a href="#local-6989586621681062045"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-133"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[CgIdInfo] -&gt; FCode ()
</span><a href="GHC.StgToCmm.Env.html#addBindsC"><span class="hs-identifier hs-var">addBindsC</span></a></span><span> </span><span class="annot"><span class="annottext">[CgIdInfo]
</span><a href="#local-6989586621681062042"><span class="hs-identifier hs-var">infos</span></a></span><span>
</span><span id="line-134"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[FCode ()] -&gt; FCode ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a.
(Foldable t, Monad m) =&gt;
t (m a) -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#sequence_"><span class="hs-identifier hs-var">sequence_</span></a></span><span> </span><span class="annot"><span class="annottext">[FCode ()]
</span><a href="#local-6989586621681062041"><span class="hs-identifier hs-var">fcodes</span></a></span><span>
</span><span id="line-135"></span><span>        </span><span class="hs-special">}</span><span>
</span><span id="line-136"></span><span>
</span><span id="line-137"></span><span class="hs-comment">-------------------------</span><span>
</span><span id="line-138"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgLetNoEscapeRhs"><span class="hs-identifier hs-type">cgLetNoEscapeRhs</span></a></span><span>
</span><span id="line-139"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span>          </span><span class="hs-comment">-- join point for successor of let-no-escape</span><span>
</span><span id="line-140"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span>   </span><span class="hs-comment">-- Saved cost centre</span><span>
</span><span id="line-141"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-142"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#CgStgRhs"><span class="hs-identifier hs-type">CgStgRhs</span></a></span><span>
</span><span id="line-143"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.StgToCmm.Monad.html#CgIdInfo"><span class="hs-identifier hs-type">CgIdInfo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-144"></span><span>
</span><span id="line-145"></span><span id="cgLetNoEscapeRhs"><span class="annot"><span class="annottext">cgLetNoEscapeRhs :: BlockId
-&gt; Maybe LocalReg
-&gt; Id
-&gt; GenStgRhs 'CodeGen
-&gt; FCode (CgIdInfo, FCode ())
</span><a href="GHC.StgToCmm.Expr.html#cgLetNoEscapeRhs"><span class="hs-identifier hs-var hs-var">cgLetNoEscapeRhs</span></a></span></span><span> </span><span id="local-6989586621681062036"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681062036"><span class="hs-identifier hs-var">join_id</span></a></span></span><span> </span><span id="local-6989586621681062035"><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681062035"><span class="hs-identifier hs-var">local_cc</span></a></span></span><span> </span><span id="local-6989586621681062034"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681062034"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621681062033"><span class="annot"><span class="annottext">GenStgRhs 'CodeGen
</span><a href="#local-6989586621681062033"><span class="hs-identifier hs-var">rhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-146"></span><span>  </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681062032"><span class="annot"><span class="annottext">CgIdInfo
</span><a href="#local-6989586621681062032"><span class="hs-identifier hs-var">info</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681062031"><span class="annot"><span class="annottext">FCode ()
</span><a href="#local-6989586621681062031"><span class="hs-identifier hs-var">rhs_code</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe LocalReg
-&gt; Id -&gt; GenStgRhs 'CodeGen -&gt; FCode (CgIdInfo, FCode ())
</span><a href="GHC.StgToCmm.Expr.html#cgLetNoEscapeRhsBody"><span class="hs-identifier hs-var">cgLetNoEscapeRhsBody</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681062035"><span class="hs-identifier hs-var">local_cc</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681062034"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgRhs 'CodeGen
</span><a href="#local-6989586621681062033"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-147"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681062027"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681062027"><span class="hs-identifier hs-var">bid</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Maybe (BlockId, [LocalReg]) -&gt; (BlockId, [LocalReg])
forall a. HasCallStack =&gt; String -&gt; Maybe a -&gt; a
</span><a href="GHC.Data.Maybe.html#expectJust"><span class="hs-identifier hs-var">expectJust</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cgLetNoEscapeRhs&quot;</span></span><span> </span><span class="annot"><span class="annottext">(Maybe (BlockId, [LocalReg]) -&gt; (BlockId, [LocalReg]))
-&gt; Maybe (BlockId, [LocalReg]) -&gt; (BlockId, [LocalReg])
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CgIdInfo -&gt; Maybe (BlockId, [LocalReg])
</span><a href="GHC.StgToCmm.Env.html#maybeLetNoEscape"><span class="hs-identifier hs-var">maybeLetNoEscape</span></a></span><span> </span><span class="annot"><span class="annottext">CgIdInfo
</span><a href="#local-6989586621681062032"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-148"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681062021"><span class="annot"><span class="annottext">code :: FCode ()
</span><a href="#local-6989586621681062021"><span class="hs-identifier hs-var hs-var">code</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">()
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681062020"><span class="annot"><span class="annottext">CmmAGraphScoped
</span><a href="#local-6989586621681062020"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode () -&gt; FCode ((), CmmAGraphScoped)
forall a. FCode a -&gt; FCode (a, CmmAGraphScoped)
</span><a href="GHC.StgToCmm.Monad.html#getCodeScoped"><span class="hs-identifier hs-var">getCodeScoped</span></a></span><span> </span><span class="annot"><span class="annottext">FCode ()
</span><a href="#local-6989586621681062031"><span class="hs-identifier hs-var">rhs_code</span></a></span><span>
</span><span id="line-149"></span><span>                     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; CmmAGraphScoped -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitOutOfLine"><span class="hs-identifier hs-var">emitOutOfLine</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681062027"><span class="hs-identifier hs-var">bid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(CmmAGraph -&gt; CmmAGraph) -&gt; CmmAGraphScoped -&gt; CmmAGraphScoped
forall (a :: * -&gt; * -&gt; *) b c d.
Arrow a =&gt;
a b c -&gt; a (b, d) (c, d)
</span><a href="../../base/src/Control.Arrow.html#first"><span class="hs-identifier hs-var">first</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmAGraph -&gt; CmmAGraph -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkBranch"><span class="hs-identifier hs-var">mkBranch</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681062036"><span class="hs-identifier hs-var">join_id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmAGraphScoped
</span><a href="#local-6989586621681062020"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-150"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(CgIdInfo, FCode ()) -&gt; FCode (CgIdInfo, FCode ())
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CgIdInfo
</span><a href="#local-6989586621681062032"><span class="hs-identifier hs-var">info</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">FCode ()
</span><a href="#local-6989586621681062021"><span class="hs-identifier hs-var">code</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-151"></span><span>     </span><span class="hs-special">}</span><span>
</span><span id="line-152"></span><span>
</span><span id="line-153"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgLetNoEscapeRhsBody"><span class="hs-identifier hs-type">cgLetNoEscapeRhsBody</span></a></span><span>
</span><span id="line-154"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span>   </span><span class="hs-comment">-- Saved cost centre</span><span>
</span><span id="line-155"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-156"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#CgStgRhs"><span class="hs-identifier hs-type">CgStgRhs</span></a></span><span>
</span><span id="line-157"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.StgToCmm.Monad.html#CgIdInfo"><span class="hs-identifier hs-type">CgIdInfo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-158"></span><span id="cgLetNoEscapeRhsBody"><span class="annot"><span class="annottext">cgLetNoEscapeRhsBody :: Maybe LocalReg
-&gt; Id -&gt; GenStgRhs 'CodeGen -&gt; FCode (CgIdInfo, FCode ())
</span><a href="GHC.StgToCmm.Expr.html#cgLetNoEscapeRhsBody"><span class="hs-identifier hs-var hs-var">cgLetNoEscapeRhsBody</span></a></span></span><span> </span><span id="local-6989586621681062015"><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681062015"><span class="hs-identifier hs-var">local_cc</span></a></span></span><span> </span><span id="local-6989586621681062014"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681062014"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgRhsClosure"><span class="hs-identifier hs-type">StgRhsClosure</span></a></span><span> </span><span class="annot"><span class="annottext">XRhsClosure 'CodeGen
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681062012"><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621681062012"><span class="hs-identifier hs-var">cc</span></a></span></span><span> </span><span id="local-6989586621681062011"><span class="annot"><span class="annottext">UpdateFlag
</span><a href="#local-6989586621681062011"><span class="hs-identifier hs-var">_upd</span></a></span></span><span> </span><span id="local-6989586621681062010"><span class="annot"><span class="annottext">[BinderP 'CodeGen]
</span><a href="#local-6989586621681062010"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span id="local-6989586621681062009"><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681062009"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-159"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
-&gt; Maybe LocalReg
-&gt; CostCentreStack
-&gt; [NonVoid Id]
-&gt; CgStgExpr
-&gt; FCode (CgIdInfo, FCode ())
</span><a href="GHC.StgToCmm.Expr.html#cgLetNoEscapeClosure"><span class="hs-identifier hs-var">cgLetNoEscapeClosure</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681062014"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681062015"><span class="hs-identifier hs-var">local_cc</span></a></span><span> </span><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621681062012"><span class="hs-identifier hs-var">cc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; [NonVoid Id]
</span><a href="GHC.StgToCmm.Closure.html#nonVoidIds"><span class="hs-identifier hs-var">nonVoidIds</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
[BinderP 'CodeGen]
</span><a href="#local-6989586621681062010"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681062009"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-160"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgLetNoEscapeRhsBody"><span class="hs-identifier hs-var">cgLetNoEscapeRhsBody</span></a></span><span> </span><span id="local-6989586621681062006"><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681062006"><span class="hs-identifier hs-var">local_cc</span></a></span></span><span> </span><span id="local-6989586621681062005"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681062005"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgRhsCon"><span class="hs-identifier hs-type">StgRhsCon</span></a></span><span> </span><span id="local-6989586621681062003"><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621681062003"><span class="hs-identifier hs-var">cc</span></a></span></span><span> </span><span id="local-6989586621681062002"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681062002"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span id="local-6989586621681062001"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681062001"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-161"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
-&gt; Maybe LocalReg
-&gt; CostCentreStack
-&gt; [NonVoid Id]
-&gt; CgStgExpr
-&gt; FCode (CgIdInfo, FCode ())
</span><a href="GHC.StgToCmm.Expr.html#cgLetNoEscapeClosure"><span class="hs-identifier hs-var">cgLetNoEscapeClosure</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681062005"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681062006"><span class="hs-identifier hs-var">local_cc</span></a></span><span> </span><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621681062003"><span class="hs-identifier hs-var">cc</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-162"></span><span>      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; [StgArg] -&gt; [Type] -&gt; CgStgExpr
forall (pass :: StgPass).
DataCon -&gt; [StgArg] -&gt; [Type] -&gt; GenStgExpr pass
</span><a href="GHC.Stg.Syntax.html#StgConApp"><span class="hs-identifier hs-var">StgConApp</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681062002"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681062001"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; [Type]
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cgLetNoEscapeRhsBody&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; [Type]) -&gt; SDoc -&gt; [Type]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-163"></span><span>                           </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;StgRhsCon doesn't have type args&quot;</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-164"></span><span>        </span><span class="hs-comment">-- For a constructor RHS we want to generate a single chunk of</span><span>
</span><span id="line-165"></span><span>        </span><span class="hs-comment">-- code which can be jumped to from many places, which will</span><span>
</span><span id="line-166"></span><span>        </span><span class="hs-comment">-- return the constructor. It's easy; just behave as if it</span><span>
</span><span id="line-167"></span><span>        </span><span class="hs-comment">-- was an StgRhsClosure with a ConApp inside!</span><span>
</span><span id="line-168"></span><span>
</span><span id="line-169"></span><span class="hs-comment">-------------------------</span><span>
</span><span id="line-170"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgLetNoEscapeClosure"><span class="hs-identifier hs-type">cgLetNoEscapeClosure</span></a></span><span>
</span><span id="line-171"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>                   </span><span class="hs-comment">-- binder</span><span>
</span><span id="line-172"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span>       </span><span class="hs-comment">-- Slot for saved current cost centre</span><span>
</span><span id="line-173"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.CostCentre.html#CostCentreStack"><span class="hs-identifier hs-type">CostCentreStack</span></a></span><span>      </span><span class="hs-comment">-- XXX: *** NOT USED *** why not?</span><span>
</span><span id="line-174"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.StgToCmm.Closure.html#NonVoid"><span class="hs-identifier hs-type">NonVoid</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span>         </span><span class="hs-comment">-- Args (as in \ args -&gt; body)</span><span>
</span><span id="line-175"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#CgStgExpr"><span class="hs-identifier hs-type">CgStgExpr</span></a></span><span>            </span><span class="hs-comment">-- Body (as in above)</span><span>
</span><span id="line-176"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.StgToCmm.Monad.html#CgIdInfo"><span class="hs-identifier hs-type">CgIdInfo</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-177"></span><span>
</span><span id="line-178"></span><span id="cgLetNoEscapeClosure"><span class="annot"><span class="annottext">cgLetNoEscapeClosure :: Id
-&gt; Maybe LocalReg
-&gt; CostCentreStack
-&gt; [NonVoid Id]
-&gt; CgStgExpr
-&gt; FCode (CgIdInfo, FCode ())
</span><a href="GHC.StgToCmm.Expr.html#cgLetNoEscapeClosure"><span class="hs-identifier hs-var hs-var">cgLetNoEscapeClosure</span></a></span></span><span> </span><span id="local-6989586621681061998"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061998"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621681061997"><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681061997"><span class="hs-identifier hs-var">cc_slot</span></a></span></span><span> </span><span id="local-6989586621681061996"><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621681061996"><span class="hs-identifier hs-var">_unused_cc</span></a></span></span><span> </span><span id="local-6989586621681061995"><span class="annot"><span class="annottext">[NonVoid Id]
</span><a href="#local-6989586621681061995"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span id="local-6989586621681061994"><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681061994"><span class="hs-identifier hs-var">body</span></a></span></span><span>
</span><span id="line-179"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681061993"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061993"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-180"></span><span>       </span><span class="annot"><span class="annottext">(CgIdInfo, FCode ()) -&gt; FCode (CgIdInfo, FCode ())
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Id -&gt; [NonVoid Id] -&gt; CgIdInfo
</span><a href="GHC.StgToCmm.Env.html#lneIdInfo"><span class="hs-identifier hs-var">lneIdInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061993"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061998"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">[NonVoid Id]
</span><a href="#local-6989586621681061995"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-181"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">FCode ()
</span><a href="#local-6989586621681061991"><span class="hs-identifier hs-var">code</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-182"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-183"></span><span>   </span><span id="local-6989586621681061991"><span class="annot"><span class="annottext">code :: FCode ()
</span><a href="#local-6989586621681061991"><span class="hs-identifier hs-var hs-var">code</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FCode () -&gt; FCode ()
forall a. FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Monad.html#forkLneBody"><span class="hs-identifier hs-var">forkLneBody</span></a></span><span> </span><span class="annot"><span class="annottext">(FCode () -&gt; FCode ()) -&gt; FCode () -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-184"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; [NonVoid Id] -&gt; FCode () -&gt; FCode ()
forall a. Name -&gt; [NonVoid Id] -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Ticky.html#withNewTickyCounterLNE"><span class="hs-identifier hs-var">withNewTickyCounterLNE</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061998"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[NonVoid Id]
</span><a href="#local-6989586621681061995"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">(FCode () -&gt; FCode ()) -&gt; FCode () -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-185"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe LocalReg -&gt; FCode ()
</span><a href="GHC.StgToCmm.Prof.html#restoreCurrentCostCentre"><span class="hs-identifier hs-var">restoreCurrentCostCentre</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681061997"><span class="hs-identifier hs-var">cc_slot</span></a></span><span>
</span><span id="line-186"></span><span>            </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061982"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681061982"><span class="hs-identifier hs-var">arg_regs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[NonVoid Id] -&gt; FCode [LocalReg]
</span><a href="GHC.StgToCmm.Env.html#bindArgsToRegs"><span class="hs-identifier hs-var">bindArgsToRegs</span></a></span><span> </span><span class="annot"><span class="annottext">[NonVoid Id]
</span><a href="#local-6989586621681061995"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-187"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">FCode ReturnKind -&gt; FCode ()
forall (f :: * -&gt; *) a. Functor f =&gt; f a -&gt; f ()
</span><a href="../../base/src/Data.Functor.html#void"><span class="hs-identifier hs-var">void</span></a></span><span> </span><span class="annot"><span class="annottext">(FCode ReturnKind -&gt; FCode ()) -&gt; FCode ReturnKind -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg] -&gt; FCode ReturnKind -&gt; FCode ReturnKind
forall a. [LocalReg] -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#noEscapeHeapCheck"><span class="hs-identifier hs-var">noEscapeHeapCheck</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681061982"><span class="hs-identifier hs-var">arg_regs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FCode ()
</span><a href="GHC.StgToCmm.Ticky.html#tickyEnterLNE"><span class="hs-identifier hs-var">tickyEnterLNE</span></a></span><span> </span><span class="annot"><span class="annottext">FCode () -&gt; FCode ReturnKind -&gt; FCode ReturnKind
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CgStgExpr -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681061994"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-188"></span><span>
</span><span id="line-189"></span><span>
</span><span id="line-190"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-191"></span><span class="hs-comment">--              Case expressions</span><span>
</span><span id="line-192"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-193"></span><span>
</span><span id="line-194"></span><span class="hs-comment">{- Note [Compiling case expressions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It is quite interesting to decide whether to put a heap-check at the
start of each alternative.  Of course we certainly have to do so if
the case forces an evaluation, or if there is a primitive op which can
trigger GC.

A more interesting situation is this (a Plan-B situation)

        !P!;
        ...P...
        case x# of
          0#      -&gt; !Q!; ...Q...
          default -&gt; !R!; ...R...

where !x! indicates a possible heap-check point. The heap checks
in the alternatives *can* be omitted, in which case the topmost
heapcheck will take their worst case into account.

In favour of omitting !Q!, !R!:

 - *May* save a heap overflow test,
   if ...P... allocates anything.

 - We can use relative addressing from a single Hp to
   get at all the closures so allocated.

 - No need to save volatile vars etc across heap checks
   in !Q!, !R!

Against omitting !Q!, !R!

  - May put a heap-check into the inner loop.  Suppose
        the main loop is P -&gt; R -&gt; P -&gt; R...
        Q is the loop exit, and only it does allocation.
    This only hurts us if P does no allocation.  If P allocates,
    then there is a heap check in the inner loop anyway.

  - May do more allocation than reqd.  This sometimes bites us
    badly.  For example, nfib (ha!) allocates about 30\% more space if the
    worst-casing is done, because many many calls to nfib are leaf calls
    which don't need to allocate anything.

    We can un-allocate, but that costs an instruction

Neither problem hurts us if there is only one alternative.

Suppose the inner loop is P-&gt;R-&gt;P-&gt;R etc.  Then here is
how many heap checks we get in the *inner loop* under various
conditions

  Alloc   Heap check in branches (!Q!, !R!)?
  P Q R      yes     no (absorb to !P!)
--------------------------------------
  n n n      0          0
  n y n      0          1
  n . y      1          1
  y . y      2          1
  y . n      1          1

Best choices: absorb heap checks from Q and R into !P! iff
  a) P itself does some allocation
or
  b) P does allocation, or there is exactly one alternative

We adopt (b) because that is more likely to put the heap check at the
entry to a function, when not many things are live.  After a bunch of
single-branch cases, we may have lots of things live

Hence: two basic plans for

        case e of r { alts }

------ Plan A: the general case ---------

        ...save current cost centre...

        ...code for e,
           with sequel (SetLocals r)

        ...restore current cost centre...
        ...code for alts...
        ...alts do their own heap checks

------ Plan B: special case when ---------
  (i)  e does not allocate or call GC
  (ii) either upstream code performs allocation
       or there is just one alternative

  Then heap allocation in the (single) case branch
  is absorbed by the upstream check.
  Very common example: primops on unboxed values

        ...code for e,
           with sequel (SetLocals r)...

        ...code for alts...
        ...no heap check...
-}</span><span>
</span><span id="line-293"></span><span>
</span><span id="line-294"></span><span>
</span><span id="line-295"></span><span>
</span><span id="line-296"></span><span class="hs-comment">-------------------------------------</span><span>
</span><span id="line-297"></span><span class="hs-keyword">data</span><span> </span><span id="GcPlan"><span class="annot"><a href="GHC.StgToCmm.Expr.html#GcPlan"><span class="hs-identifier hs-var">GcPlan</span></a></span></span><span>
</span><span id="line-298"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="GcInAlts"><span class="annot"><a href="GHC.StgToCmm.Expr.html#GcInAlts"><span class="hs-identifier hs-var">GcInAlts</span></a></span></span><span>            </span><span class="hs-comment">-- Put a GC check at the start the case alternatives,</span><span>
</span><span id="line-299"></span><span>        </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span class="hs-special">]</span><span>      </span><span class="hs-comment">-- which binds these registers</span><span>
</span><span id="line-300"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="NoGcInAlts"><span class="annot"><a href="GHC.StgToCmm.Expr.html#NoGcInAlts"><span class="hs-identifier hs-var">NoGcInAlts</span></a></span></span><span>          </span><span class="hs-comment">-- The scrutinee is a primitive value, or a call to a</span><span>
</span><span id="line-301"></span><span>                        </span><span class="hs-comment">-- primitive op which does no GC.  Absorb the allocation</span><span>
</span><span id="line-302"></span><span>                        </span><span class="hs-comment">-- of the case alternative(s) into the upstream check</span><span>
</span><span id="line-303"></span><span>
</span><span id="line-304"></span><span class="hs-comment">-------------------------------------</span><span>
</span><span id="line-305"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgCase"><span class="hs-identifier hs-type">cgCase</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#CgStgExpr"><span class="hs-identifier hs-type">CgStgExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#AltType"><span class="hs-identifier hs-type">AltType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#CgStgAlt"><span class="hs-identifier hs-type">CgStgAlt</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#ReturnKind"><span class="hs-identifier hs-type">ReturnKind</span></a></span><span>
</span><span id="line-306"></span><span>
</span><span id="line-307"></span><span class="hs-comment">{-
Note [Scrutinising VoidRep]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we have this STG code:
   f = \[s : State# RealWorld] -&gt;
       case s of _ -&gt; blah
This is very odd.  Why are we scrutinising a state token?  But it
can arise with bizarre NOINLINE pragmas (#9964)
    crash :: IO ()
    crash = IO (\s -&gt; let {-# NOINLINE s' #-}
                          s' = s
                      in (# s', () #))

Now the trouble is that 's' has VoidRep, and we do not bind void
arguments in the environment; they don't live anywhere.  See the
calls to nonVoidIds in various places.  So we must not look up
's' in the environment.  Instead, just evaluate the RHS!  Simple.

Note [Dead-binder optimisation]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A case-binder, or data-constructor argument, may be marked as dead,
because we preserve occurrence-info on binders in GHC.Core.Tidy (see
GHC.Core.Tidy.tidyIdBndr).

If the binder is dead, we can sometimes eliminate a load.  While
CmmSink will eliminate that load, it's very easy to kill it at source
(giving CmmSink less work to do), and in any case CmmSink only runs
with -O. Since the majority of case binders are dead, this
optimisation probably still has a great benefit-cost ratio and we want
to keep it for -O0. See also Phab:D5358.

This probably also was the reason for occurrence hack in Phab:D5339 to
exist, perhaps because the occurrence information preserved by
'GHC.Core.Tidy.tidyIdBndr' was insufficient.  But now that CmmSink does the
job we deleted the hacks.
-}</span><span>
</span><span id="line-343"></span><span>
</span><span id="line-344"></span><span id="cgCase"><span class="annot"><span class="annottext">cgCase :: CgStgExpr
-&gt; Id -&gt; AltType -&gt; [GenStgAlt 'CodeGen] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgCase"><span class="hs-identifier hs-var hs-var">cgCase</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgApp"><span class="hs-identifier hs-type">StgApp</span></a></span><span> </span><span id="local-6989586621681061975"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061975"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#PrimAlt"><span class="hs-identifier hs-type">PrimAlt</span></a></span><span> </span><span class="annot"><span class="annottext">PrimRep
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681061973"><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061973"><span class="hs-identifier hs-var">alts</span></a></span></span><span>
</span><span id="line-345"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">PrimRep -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isVoidRep"><span class="hs-identifier hs-var">isVoidRep</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; PrimRep
</span><a href="GHC.StgToCmm.Closure.html#idPrimRep"><span class="hs-identifier hs-var">idPrimRep</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061975"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- See Note [Scrutinising VoidRep]</span><span>
</span><span id="line-346"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><a href="GHC.Core.html#DEFAULT"><span class="hs-identifier hs-var">DEFAULT</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[BinderP 'CodeGen]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681061969"><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681061969"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061973"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-347"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CgStgExpr -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681061969"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-348"></span><span>
</span><span id="line-349"></span><span class="hs-comment">{- Note [Dodgy unsafeCoerce 1]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
    case (x :: HValue) |&gt; co of (y :: MutVar# Int)
        DEFAULT -&gt; ...
We want to generate an assignment
     y := x
We want to allow this assignment to be generated in the case when the
types are compatible, because this allows some slightly-dodgy but
occasionally-useful casts to be used, such as in GHC.Runtime.Heap.Inspect
where we cast an HValue to a MutVar# so we can print out the contents
of the MutVar#.  If instead we generate code that enters the HValue,
then we'll get a runtime panic, because the HValue really is a
MutVar#.  The types are compatible though, so we can just generate an
assignment.
-}</span><span>
</span><span id="line-365"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgCase"><span class="hs-identifier hs-var">cgCase</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgApp"><span class="hs-identifier hs-type">StgApp</span></a></span><span> </span><span id="local-6989586621681061968"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061968"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681061967"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061967"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621681061966"><span class="annot"><span class="annottext">alt_type :: AltType
</span><a href="#local-6989586621681061966"><span class="hs-identifier hs-var">alt_type</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#PrimAlt"><span class="hs-identifier hs-type">PrimAlt</span></a></span><span> </span><span class="annot"><span class="annottext">PrimRep
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681061965"><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061965"><span class="hs-identifier hs-var">alts</span></a></span></span><span>
</span><span id="line-366"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Bool
Type -&gt; Bool
</span><a href="GHC.Core.Type.html#isUnliftedType"><span class="hs-identifier hs-var">isUnliftedType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061968"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Note [Dodgy unsafeCoerce 1]</span><span>
</span><span id="line-367"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- assignment suffices for unlifted types</span><span>
</span><span id="line-368"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681061963"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061963"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-369"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; FCode () -&gt; FCode ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; Bool
</span><a href="#local-6989586621681061962"><span class="hs-identifier hs-var">reps_compatible</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061963"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(FCode () -&gt; FCode ()) -&gt; FCode () -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-370"></span><span>           </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; FCode ()
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cgCase: reps do not match, perhaps a dodgy unsafeCoerce?&quot;</span></span><span>
</span><span id="line-371"></span><span>                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; SDoc
</span><a href="#local-6989586621681061961"><span class="hs-identifier hs-var">pp_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061968"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
</span><a href="#local-6989586621681061961"><span class="hs-identifier hs-var">pp_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061967"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-372"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061959"><span class="annot"><span class="annottext">CgIdInfo
</span><a href="#local-6989586621681061959"><span class="hs-identifier hs-var">v_info</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; FCode CgIdInfo
</span><a href="GHC.StgToCmm.Env.html#getCgIdInfo"><span class="hs-identifier hs-var">getCgIdInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061968"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-373"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitAssign"><span class="hs-identifier hs-var">emitAssign</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; NonVoid Id -&gt; LocalReg
</span><a href="GHC.StgToCmm.Env.html#idToReg"><span class="hs-identifier hs-var">idToReg</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061963"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; NonVoid Id
forall a. a -&gt; NonVoid a
</span><a href="GHC.StgToCmm.Closure.html#NonVoid"><span class="hs-identifier hs-var">NonVoid</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061967"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-374"></span><span>                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CgIdInfo -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Env.html#idInfoToAmode"><span class="hs-identifier hs-var">idInfoToAmode</span></a></span><span> </span><span class="annot"><span class="annottext">CgIdInfo
</span><a href="#local-6989586621681061959"><span class="hs-identifier hs-var">v_info</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-375"></span><span>       </span><span class="hs-comment">-- Add bndr to the environment</span><span>
</span><span id="line-376"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">NonVoid Id -&gt; FCode LocalReg
</span><a href="GHC.StgToCmm.Env.html#bindArgToReg"><span class="hs-identifier hs-var">bindArgToReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; NonVoid Id
forall a. a -&gt; NonVoid a
</span><a href="GHC.StgToCmm.Closure.html#NonVoid"><span class="hs-identifier hs-var">NonVoid</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061967"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-377"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
-&gt; NonVoid Id
-&gt; AltType
-&gt; [GenStgAlt 'CodeGen]
-&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgAlts"><span class="hs-identifier hs-var">cgAlts</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GcPlan
</span><a href="GHC.StgToCmm.Expr.html#NoGcInAlts"><span class="hs-identifier hs-var">NoGcInAlts</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">ReturnKind
</span><a href="GHC.StgToCmm.Monad.html#AssignedDirectly"><span class="hs-identifier hs-var">AssignedDirectly</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; NonVoid Id
forall a. a -&gt; NonVoid a
</span><a href="GHC.StgToCmm.Closure.html#NonVoid"><span class="hs-identifier hs-var">NonVoid</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061967"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">AltType
</span><a href="#local-6989586621681061966"><span class="hs-identifier hs-var">alt_type</span></a></span><span> </span><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061965"><span class="hs-identifier hs-var">alts</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-378"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-379"></span><span>    </span><span id="local-6989586621681061962"><span class="annot"><span class="annottext">reps_compatible :: Platform -&gt; Bool
</span><a href="#local-6989586621681061962"><span class="hs-identifier hs-var hs-var">reps_compatible</span></a></span></span><span> </span><span id="local-6989586621681061950"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061950"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; PrimRep -&gt; PrimRep -&gt; Bool
</span><a href="GHC.Core.TyCon.html#primRepCompatible"><span class="hs-identifier hs-var">primRepCompatible</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061950"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; PrimRep
</span><a href="GHC.StgToCmm.Closure.html#idPrimRep"><span class="hs-identifier hs-var">idPrimRep</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061968"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; PrimRep
</span><a href="GHC.StgToCmm.Closure.html#idPrimRep"><span class="hs-identifier hs-var">idPrimRep</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061967"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-380"></span><span>
</span><span id="line-381"></span><span>    </span><span id="local-6989586621681061961"><span class="annot"><span class="annottext">pp_bndr :: Id -&gt; SDoc
</span><a href="#local-6989586621681061961"><span class="hs-identifier hs-var hs-var">pp_bndr</span></a></span></span><span> </span><span id="local-6989586621681061943"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061943"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061943"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#dcolon"><span class="hs-identifier hs-var">dcolon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061943"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PrimRep -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; PrimRep
</span><a href="GHC.StgToCmm.Closure.html#idPrimRep"><span class="hs-identifier hs-var">idPrimRep</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061943"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-382"></span><span>
</span><span id="line-383"></span><span class="hs-comment">{- Note [Dodgy unsafeCoerce 2, #3132]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In all other cases of a lifted Id being cast to an unlifted type, the
Id should be bound to bottom, otherwise this is an unsafe use of
unsafeCoerce.  We can generate code to enter the Id and assume that
it will never return.  Hence, we emit the usual enter/return code, and
because bottom must be untagged, it will be entered.  The Sequel is a
type-correct assignment, albeit bogus.  The (dead) continuation loops;
it would be better to invoke some kind of panic function here.
-}</span><span>
</span><span id="line-393"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgCase"><span class="hs-identifier hs-var">cgCase</span></a></span><span> </span><span id="local-6989586621681061938"><span class="annot"><span class="annottext">scrut :: CgStgExpr
</span><a href="#local-6989586621681061938"><span class="hs-identifier hs-var">scrut</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgApp"><span class="hs-identifier hs-type">StgApp</span></a></span><span> </span><span id="local-6989586621681061937"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061937"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#PrimAlt"><span class="hs-identifier hs-type">PrimAlt</span></a></span><span> </span><span class="annot"><span class="annottext">PrimRep
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-394"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681061936"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061936"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-395"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061935"><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681061935"><span class="hs-identifier hs-var">mb_cc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; FCode (Maybe LocalReg)
</span><a href="GHC.StgToCmm.Expr.html#maybeSaveCostCentre"><span class="hs-identifier hs-var">maybeSaveCostCentre</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-396"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">ReturnKind
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Sequel -&gt; FCode ReturnKind -&gt; FCode ReturnKind
forall a. Sequel -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Monad.html#withSequel"><span class="hs-identifier hs-var">withSequel</span></a></span><span>
</span><span id="line-397"></span><span>                  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[LocalReg] -&gt; Bool -&gt; Sequel
</span><a href="GHC.StgToCmm.Monad.html#AssignTo"><span class="hs-identifier hs-var">AssignTo</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Platform -&gt; NonVoid Id -&gt; LocalReg
</span><a href="GHC.StgToCmm.Env.html#idToReg"><span class="hs-identifier hs-var">idToReg</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061936"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; NonVoid Id
forall a. a -&gt; NonVoid a
</span><a href="GHC.StgToCmm.Closure.html#NonVoid"><span class="hs-identifier hs-var">NonVoid</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061937"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CgStgExpr -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681061938"><span class="hs-identifier hs-var">scrut</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-398"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe LocalReg -&gt; FCode ()
</span><a href="GHC.StgToCmm.Prof.html#restoreCurrentCostCentre"><span class="hs-identifier hs-var">restoreCurrentCostCentre</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681061935"><span class="hs-identifier hs-var">mb_cc</span></a></span><span>
</span><span id="line-399"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitComment"><span class="hs-identifier hs-var">emitComment</span></a></span><span> </span><span class="annot"><span class="annottext">(FastString -&gt; FCode ()) -&gt; FastString -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#mkFastString"><span class="hs-identifier hs-var">mkFastString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;should be unreachable code&quot;</span></span><span>
</span><span id="line-400"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061933"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061933"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode BlockId
forall (m :: * -&gt; *). MonadUnique m =&gt; m BlockId
</span><a href="GHC.Cmm.BlockId.html#newBlockId"><span class="hs-identifier hs-var">newBlockId</span></a></span><span>
</span><span id="line-401"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitLabel"><span class="hs-identifier hs-var">emitLabel</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061933"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-402"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkBranch"><span class="hs-identifier hs-var">mkBranch</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061933"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- an infinite loop</span><span>
</span><span id="line-403"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">ReturnKind -&gt; FCode ReturnKind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ReturnKind
</span><a href="GHC.StgToCmm.Monad.html#AssignedDirectly"><span class="hs-identifier hs-var">AssignedDirectly</span></a></span><span>
</span><span id="line-404"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-405"></span><span>
</span><span id="line-406"></span><span class="hs-comment">{- Note [Handle seq#]
~~~~~~~~~~~~~~~~~~~~~
See Note [seq# magic] in GHC.Core.Opt.ConstantFold.
The special case for seq# in cgCase does this:

  case seq# a s of v
    (# s', a' #) -&gt; e
==&gt;
  case a of v
    (# s', a' #) -&gt; e

(taking advantage of the fact that the return convention for (# State#, a #)
is the same as the return convention for just 'a')
-}</span><span>
</span><span id="line-420"></span><span>
</span><span id="line-421"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgCase"><span class="hs-identifier hs-var">cgCase</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgOpApp"><span class="hs-identifier hs-type">StgOpApp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgPrimOp"><span class="hs-identifier hs-type">StgPrimOp</span></a></span><span> </span><span class="annot"><span class="annottext">PrimOp
</span><a href="GHC.Builtin.PrimOps.html#SeqOp"><span class="hs-identifier hs-var">SeqOp</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgVarArg"><span class="hs-identifier hs-type">StgVarArg</span></a></span><span> </span><span id="local-6989586621681061930"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061930"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">StgArg
</span><span class="hs-identifier">_</span></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681061929"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061929"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621681061928"><span class="annot"><span class="annottext">AltType
</span><a href="#local-6989586621681061928"><span class="hs-identifier hs-var">alt_type</span></a></span></span><span> </span><span id="local-6989586621681061927"><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061927"><span class="hs-identifier hs-var">alts</span></a></span></span><span>
</span><span id="line-422"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- Note [Handle seq#]</span><span>
</span><span id="line-423"></span><span>    </span><span class="hs-comment">-- And see Note [seq# magic] in GHC.Core.Opt.ConstantFold</span><span>
</span><span id="line-424"></span><span>    </span><span class="hs-comment">-- Use the same return convention as vanilla 'a'.</span><span>
</span><span id="line-425"></span><span>    </span><span class="annot"><span class="annottext">CgStgExpr
-&gt; Id -&gt; AltType -&gt; [GenStgAlt 'CodeGen] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgCase"><span class="hs-identifier hs-var">cgCase</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; [StgArg] -&gt; CgStgExpr
forall (pass :: StgPass). Id -&gt; [StgArg] -&gt; GenStgExpr pass
</span><a href="GHC.Stg.Syntax.html#StgApp"><span class="hs-identifier hs-var">StgApp</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061930"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061929"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">AltType
</span><a href="#local-6989586621681061928"><span class="hs-identifier hs-var">alt_type</span></a></span><span> </span><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061927"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-426"></span><span>
</span><span id="line-427"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgCase"><span class="hs-identifier hs-var">cgCase</span></a></span><span> </span><span id="local-6989586621681061926"><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681061926"><span class="hs-identifier hs-var">scrut</span></a></span></span><span> </span><span id="local-6989586621681061925"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061925"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621681061924"><span class="annot"><span class="annottext">AltType
</span><a href="#local-6989586621681061924"><span class="hs-identifier hs-var">alt_type</span></a></span></span><span> </span><span id="local-6989586621681061923"><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061923"><span class="hs-identifier hs-var">alts</span></a></span></span><span>
</span><span id="line-428"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- the general case</span><span>
</span><span id="line-429"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681061922"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061922"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-430"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061921"><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061921"><span class="hs-identifier hs-var">up_hp_usg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode RepArity
</span><a href="GHC.StgToCmm.Monad.html#getVirtHp"><span class="hs-identifier hs-var">getVirtHp</span></a></span><span>        </span><span class="hs-comment">-- Upstream heap usage</span><span>
</span><span id="line-431"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681061919"><span class="annot"><span class="annottext">ret_bndrs :: [NonVoid Id]
</span><a href="#local-6989586621681061919"><span class="hs-identifier hs-var hs-var">ret_bndrs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; AltType -&gt; [GenStgAlt 'CodeGen] -&gt; [NonVoid Id]
</span><a href="GHC.StgToCmm.Expr.html#chooseReturnBndrs"><span class="hs-identifier hs-var">chooseReturnBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061925"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">AltType
</span><a href="#local-6989586621681061924"><span class="hs-identifier hs-var">alt_type</span></a></span><span> </span><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061923"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-432"></span><span>             </span><span id="local-6989586621681061917"><span class="annot"><span class="annottext">alt_regs :: [LocalReg]
</span><a href="#local-6989586621681061917"><span class="hs-identifier hs-var hs-var">alt_regs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(NonVoid Id -&gt; LocalReg) -&gt; [NonVoid Id] -&gt; [LocalReg]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; NonVoid Id -&gt; LocalReg
</span><a href="GHC.StgToCmm.Env.html#idToReg"><span class="hs-identifier hs-var">idToReg</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061922"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[NonVoid Id]
</span><a href="#local-6989586621681061919"><span class="hs-identifier hs-var">ret_bndrs</span></a></span><span>
</span><span id="line-433"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061916"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681061916"><span class="hs-identifier hs-var">simple_scrut</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CgStgExpr -&gt; AltType -&gt; FCode Bool
</span><a href="GHC.StgToCmm.Expr.html#isSimpleScrut"><span class="hs-identifier hs-var">isSimpleScrut</span></a></span><span> </span><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681061926"><span class="hs-identifier hs-var">scrut</span></a></span><span> </span><span class="annot"><span class="annottext">AltType
</span><a href="#local-6989586621681061924"><span class="hs-identifier hs-var">alt_type</span></a></span><span>
</span><span id="line-434"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681061911"><span class="annot"><span class="annottext">do_gc :: Bool
</span><a href="#local-6989586621681061911"><span class="hs-identifier hs-var hs-var">do_gc</span></a></span></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CgStgExpr -&gt; Bool
forall {pass :: StgPass}. GenStgExpr pass -&gt; Bool
</span><a href="#local-6989586621681061910"><span class="hs-identifier hs-var">is_cmp_op</span></a></span><span> </span><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681061926"><span class="hs-identifier hs-var">scrut</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>  </span><span class="hs-comment">-- See Note [GC for conditionals]</span><span>
</span><span id="line-435"></span><span>                    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681061916"><span class="hs-identifier hs-var">simple_scrut</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-436"></span><span>                    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[(AltCon, [Id], CgStgExpr)] -&gt; Bool
forall a. [a] -&gt; Bool
</span><a href="GHC.Utils.Misc.html#isSingleton"><span class="hs-identifier hs-var">isSingleton</span></a></span><span> </span><span class="annot"><span class="annottext">[(AltCon, [Id], CgStgExpr)]
[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061923"><span class="hs-identifier hs-var">alts</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-437"></span><span>                    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061921"><span class="hs-identifier hs-var">up_hp_usg</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity -&gt; RepArity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><span class="hs-number">0</span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-438"></span><span>                    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-439"></span><span>               </span><span class="hs-comment">-- cf Note [Compiling case expressions]</span><span>
</span><span id="line-440"></span><span>             </span><span id="local-6989586621681061906"><span class="annot"><span class="annottext">gc_plan :: GcPlan
</span><a href="#local-6989586621681061906"><span class="hs-identifier hs-var hs-var">gc_plan</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681061911"><span class="hs-identifier hs-var">do_gc</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">[LocalReg] -&gt; GcPlan
</span><a href="GHC.StgToCmm.Expr.html#GcInAlts"><span class="hs-identifier hs-var">GcInAlts</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681061917"><span class="hs-identifier hs-var">alt_regs</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">GcPlan
</span><a href="GHC.StgToCmm.Expr.html#NoGcInAlts"><span class="hs-identifier hs-var">NoGcInAlts</span></a></span><span>
</span><span id="line-441"></span><span>
</span><span id="line-442"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061905"><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681061905"><span class="hs-identifier hs-var">mb_cc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; FCode (Maybe LocalReg)
</span><a href="GHC.StgToCmm.Expr.html#maybeSaveCostCentre"><span class="hs-identifier hs-var">maybeSaveCostCentre</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681061916"><span class="hs-identifier hs-var">simple_scrut</span></a></span><span>
</span><span id="line-443"></span><span>
</span><span id="line-444"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681061904"><span class="annot"><span class="annottext">sequel :: Sequel
</span><a href="#local-6989586621681061904"><span class="hs-identifier hs-var hs-var">sequel</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[LocalReg] -&gt; Bool -&gt; Sequel
</span><a href="GHC.StgToCmm.Monad.html#AssignTo"><span class="hs-identifier hs-var">AssignTo</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681061917"><span class="hs-identifier hs-var">alt_regs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681061911"><span class="hs-identifier hs-var">do_gc</span></a></span><span class="hs-comment">{- Note [scrut sequel] -}</span><span>
</span><span id="line-445"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061903"><span class="annot"><span class="annottext">ReturnKind
</span><a href="#local-6989586621681061903"><span class="hs-identifier hs-var">ret_kind</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Sequel -&gt; FCode ReturnKind -&gt; FCode ReturnKind
forall a. Sequel -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Monad.html#withSequel"><span class="hs-identifier hs-var">withSequel</span></a></span><span> </span><span class="annot"><span class="annottext">Sequel
</span><a href="#local-6989586621681061904"><span class="hs-identifier hs-var">sequel</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CgStgExpr -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681061926"><span class="hs-identifier hs-var">scrut</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-446"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe LocalReg -&gt; FCode ()
</span><a href="GHC.StgToCmm.Prof.html#restoreCurrentCostCentre"><span class="hs-identifier hs-var">restoreCurrentCostCentre</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681061905"><span class="hs-identifier hs-var">mb_cc</span></a></span><span>
</span><span id="line-447"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[NonVoid Id] -&gt; FCode [LocalReg]
</span><a href="GHC.StgToCmm.Env.html#bindArgsToRegs"><span class="hs-identifier hs-var">bindArgsToRegs</span></a></span><span> </span><span class="annot"><span class="annottext">[NonVoid Id]
</span><a href="#local-6989586621681061919"><span class="hs-identifier hs-var">ret_bndrs</span></a></span><span>
</span><span id="line-448"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
-&gt; NonVoid Id
-&gt; AltType
-&gt; [GenStgAlt 'CodeGen]
-&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgAlts"><span class="hs-identifier hs-var">cgAlts</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GcPlan
</span><a href="#local-6989586621681061906"><span class="hs-identifier hs-var">gc_plan</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">ReturnKind
</span><a href="#local-6989586621681061903"><span class="hs-identifier hs-var">ret_kind</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; NonVoid Id
forall a. a -&gt; NonVoid a
</span><a href="GHC.StgToCmm.Closure.html#NonVoid"><span class="hs-identifier hs-var">NonVoid</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061925"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">AltType
</span><a href="#local-6989586621681061924"><span class="hs-identifier hs-var">alt_type</span></a></span><span> </span><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061923"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-449"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-450"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-451"></span><span>    </span><span id="local-6989586621681061910"><span class="annot"><span class="annottext">is_cmp_op :: GenStgExpr pass -&gt; Bool
</span><a href="#local-6989586621681061910"><span class="hs-identifier hs-var hs-var">is_cmp_op</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgOpApp"><span class="hs-identifier hs-type">StgOpApp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgPrimOp"><span class="hs-identifier hs-type">StgPrimOp</span></a></span><span> </span><span id="local-6989586621681061902"><span class="annot"><span class="annottext">PrimOp
</span><a href="#local-6989586621681061902"><span class="hs-identifier hs-var">op</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PrimOp -&gt; Bool
</span><a href="GHC.Builtin.PrimOps.html#isComparisonPrimOp"><span class="hs-identifier hs-var">isComparisonPrimOp</span></a></span><span> </span><span class="annot"><span class="annottext">PrimOp
</span><a href="#local-6989586621681061902"><span class="hs-identifier hs-var">op</span></a></span><span>
</span><span id="line-452"></span><span>    </span><span class="annot"><a href="#local-6989586621681061910"><span class="hs-identifier hs-var">is_cmp_op</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgExpr pass
</span><span class="hs-identifier">_</span></span><span>                             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-453"></span><span>
</span><span id="line-454"></span><span class="hs-comment">{- Note [GC for conditionals]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For boolean conditionals it seems that we have always done NoGcInAlts.
That is, we have always done the GC check before the conditional.
This is enshrined in the special case for
   case tagToEnum# (a&gt;b) of ...
See Note [case on bool]

It's odd, and it's flagrantly inconsistent with the rules described
Note [Compiling case expressions].  However, after eliminating the
tagToEnum# (#13397) we will have:
   case (a&gt;b) of ...
Rather than make it behave quite differently, I am testing for a
comparison operator here in the general case as well.

ToDo: figure out what the Right Rule should be.

Note [scrut sequel]
~~~~~~~~~~~~~~~~~~~
The job of the scrutinee is to assign its value(s) to alt_regs.
Additionally, if we plan to do a heap-check in the alternatives (see
Note [Compiling case expressions]), then we *must* retreat Hp to
recover any unused heap before passing control to the sequel.  If we
don't do this, then any unused heap will become slop because the heap
check will reset the heap usage. Slop in the heap breaks LDV profiling
(+RTS -hb) which needs to do a linear sweep through the nursery.


Note [Inlining out-of-line primops and heap checks]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If shouldInlinePrimOp returns True when called from GHC.StgToCmm.Expr for the
purpose of heap check placement, we *must* inline the primop later in
GHC.StgToCmm.Prim. If we don't things will go wrong.
-}</span><span>
</span><span id="line-488"></span><span>
</span><span id="line-489"></span><span class="hs-comment">-----------------</span><span>
</span><span id="line-490"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#maybeSaveCostCentre"><span class="hs-identifier hs-type">maybeSaveCostCentre</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-491"></span><span id="maybeSaveCostCentre"><span class="annot"><span class="annottext">maybeSaveCostCentre :: Bool -&gt; FCode (Maybe LocalReg)
</span><a href="GHC.StgToCmm.Expr.html#maybeSaveCostCentre"><span class="hs-identifier hs-var hs-var">maybeSaveCostCentre</span></a></span></span><span> </span><span id="local-6989586621681061900"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681061900"><span class="hs-identifier hs-var">simple_scrut</span></a></span></span><span>
</span><span id="line-492"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681061900"><span class="hs-identifier hs-var">simple_scrut</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe LocalReg -&gt; FCode (Maybe LocalReg)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe LocalReg
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-493"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FCode (Maybe LocalReg)
</span><a href="GHC.StgToCmm.Prof.html#saveCurrentCostCentre"><span class="hs-identifier hs-var">saveCurrentCostCentre</span></a></span><span>
</span><span id="line-494"></span><span>
</span><span id="line-495"></span><span>
</span><span id="line-496"></span><span class="hs-comment">-----------------</span><span>
</span><span id="line-497"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#isSimpleScrut"><span class="hs-identifier hs-type">isSimpleScrut</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#CgStgExpr"><span class="hs-identifier hs-type">CgStgExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#AltType"><span class="hs-identifier hs-type">AltType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-498"></span><span class="hs-comment">-- Simple scrutinee, does not block or allocate; hence safe to amalgamate</span><span>
</span><span id="line-499"></span><span class="hs-comment">-- heap usage from alternatives into the stuff before the case</span><span>
</span><span id="line-500"></span><span class="hs-comment">-- NB: if you get this wrong, and claim that the expression doesn't allocate</span><span>
</span><span id="line-501"></span><span class="hs-comment">--     when it does, you'll deeply mess up allocation</span><span>
</span><span id="line-502"></span><span id="isSimpleScrut"><span class="annot"><span class="annottext">isSimpleScrut :: CgStgExpr -&gt; AltType -&gt; FCode Bool
</span><a href="GHC.StgToCmm.Expr.html#isSimpleScrut"><span class="hs-identifier hs-var hs-var">isSimpleScrut</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgOpApp"><span class="hs-identifier hs-type">StgOpApp</span></a></span><span> </span><span id="local-6989586621681061899"><span class="annot"><span class="annottext">StgOp
</span><a href="#local-6989586621681061899"><span class="hs-identifier hs-var">op</span></a></span></span><span> </span><span id="local-6989586621681061898"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061898"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">AltType
</span><span class="hs-identifier">_</span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgOp -&gt; [StgArg] -&gt; FCode Bool
</span><a href="GHC.StgToCmm.Expr.html#isSimpleOp"><span class="hs-identifier hs-var">isSimpleOp</span></a></span><span> </span><span class="annot"><span class="annottext">StgOp
</span><a href="#local-6989586621681061899"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061898"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-503"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#isSimpleScrut"><span class="hs-identifier hs-var">isSimpleScrut</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgLit"><span class="hs-identifier hs-type">StgLit</span></a></span><span> </span><span class="annot"><span class="annottext">Literal
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>       </span><span class="annot"><span class="annottext">AltType
</span><span class="hs-identifier">_</span></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; FCode Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>       </span><span class="hs-comment">-- case 1# of { 0# -&gt; ..; ... }</span><span>
</span><span id="line-504"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#isSimpleScrut"><span class="hs-identifier hs-var">isSimpleScrut</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgApp"><span class="hs-identifier hs-type">StgApp</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>    </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#PrimAlt"><span class="hs-identifier hs-type">PrimAlt</span></a></span><span> </span><span class="annot"><span class="annottext">PrimRep
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; FCode Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>       </span><span class="hs-comment">-- case x# of { 0# -&gt; ..; ... }</span><span>
</span><span id="line-505"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#isSimpleScrut"><span class="hs-identifier hs-var">isSimpleScrut</span></a></span><span> </span><span class="annot"><span class="annottext">CgStgExpr
</span><span class="hs-identifier">_</span></span><span>                </span><span class="annot"><span class="annottext">AltType
</span><span class="hs-identifier">_</span></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; FCode Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-506"></span><span>
</span><span id="line-507"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#isSimpleOp"><span class="hs-identifier hs-type">isSimpleOp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#StgOp"><span class="hs-identifier hs-type">StgOp</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgArg"><span class="hs-identifier hs-type">StgArg</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-508"></span><span class="hs-comment">-- True iff the op cannot block or allocate</span><span>
</span><span id="line-509"></span><span id="isSimpleOp"><span class="annot"><span class="annottext">isSimpleOp :: StgOp -&gt; [StgArg] -&gt; FCode Bool
</span><a href="GHC.StgToCmm.Expr.html#isSimpleOp"><span class="hs-identifier hs-var hs-var">isSimpleOp</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgFCallOp"><span class="hs-identifier hs-type">StgFCallOp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.ForeignCall.html#CCall"><span class="hs-identifier hs-type">CCall</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.ForeignCall.html#CCallSpec"><span class="hs-identifier hs-type">CCallSpec</span></a></span><span> </span><span class="annot"><span class="annottext">CCallTarget
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681061893"><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681061893"><span class="hs-keyword hs-var">safe</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; FCode Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; FCode Bool) -&gt; Bool -&gt; FCode Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Safety -&gt; Bool
</span><a href="GHC.Types.ForeignCall.html#playSafe"><span class="hs-identifier hs-var">playSafe</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681061893"><span class="hs-keyword hs-var">safe</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-510"></span><span class="hs-comment">-- dataToTag# evaluates its argument, see Note [dataToTag#] in primops.txt.pp</span><span>
</span><span id="line-511"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#isSimpleOp"><span class="hs-identifier hs-var">isSimpleOp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgPrimOp"><span class="hs-identifier hs-type">StgPrimOp</span></a></span><span> </span><span class="annot"><span class="annottext">PrimOp
</span><a href="GHC.Builtin.PrimOps.html#DataToTagOp"><span class="hs-identifier hs-var">DataToTagOp</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; FCode Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-512"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#isSimpleOp"><span class="hs-identifier hs-var">isSimpleOp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgPrimOp"><span class="hs-identifier hs-type">StgPrimOp</span></a></span><span> </span><span id="local-6989586621681061890"><span class="annot"><span class="annottext">PrimOp
</span><a href="#local-6989586621681061890"><span class="hs-identifier hs-var">op</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681061889"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061889"><span class="hs-identifier hs-var">stg_args</span></a></span></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-513"></span><span>    </span><span id="local-6989586621681061888"><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681061888"><span class="hs-identifier hs-var">arg_exprs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[StgArg] -&gt; FCode [CmmExpr]
</span><a href="GHC.StgToCmm.Env.html#getNonVoidArgAmodes"><span class="hs-identifier hs-var">getNonVoidArgAmodes</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061889"><span class="hs-identifier hs-var">stg_args</span></a></span><span>
</span><span id="line-514"></span><span>    </span><span id="local-6989586621681061886"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061886"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-515"></span><span>    </span><span class="hs-comment">-- See Note [Inlining out-of-line primops and heap checks]</span><span>
</span><span id="line-516"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; FCode Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; FCode Bool) -&gt; Bool -&gt; FCode Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; PrimOp -&gt; [CmmExpr] -&gt; Bool
</span><a href="GHC.StgToCmm.Prim.html#shouldInlinePrimOp"><span class="hs-identifier hs-var">shouldInlinePrimOp</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061886"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">PrimOp
</span><a href="#local-6989586621681061890"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681061888"><span class="hs-identifier hs-var">arg_exprs</span></a></span><span>
</span><span id="line-517"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#isSimpleOp"><span class="hs-identifier hs-var">isSimpleOp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgPrimCallOp"><span class="hs-identifier hs-type">StgPrimCallOp</span></a></span><span> </span><span class="annot"><span class="annottext">PrimCall
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><span class="hs-identifier">_</span></span><span>                           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; FCode Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-518"></span><span>
</span><span id="line-519"></span><span class="hs-comment">-----------------</span><span>
</span><span id="line-520"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#chooseReturnBndrs"><span class="hs-identifier hs-type">chooseReturnBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#AltType"><span class="hs-identifier hs-type">AltType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#CgStgAlt"><span class="hs-identifier hs-type">CgStgAlt</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.StgToCmm.Closure.html#NonVoid"><span class="hs-identifier hs-type">NonVoid</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-521"></span><span class="hs-comment">-- These are the binders of a case that are assigned by the evaluation of the</span><span>
</span><span id="line-522"></span><span class="hs-comment">-- scrutinee.</span><span>
</span><span id="line-523"></span><span class="hs-comment">-- They're non-void, see Note [Post-unarisation invariants] in GHC.Stg.Unarise.</span><span>
</span><span id="line-524"></span><span id="chooseReturnBndrs"><span class="annot"><span class="annottext">chooseReturnBndrs :: Id -&gt; AltType -&gt; [GenStgAlt 'CodeGen] -&gt; [NonVoid Id]
</span><a href="GHC.StgToCmm.Expr.html#chooseReturnBndrs"><span class="hs-identifier hs-var hs-var">chooseReturnBndrs</span></a></span></span><span> </span><span id="local-6989586621681061883"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061883"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#PrimAlt"><span class="hs-identifier hs-type">PrimAlt</span></a></span><span> </span><span class="annot"><span class="annottext">PrimRep
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681061882"><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061882"><span class="hs-identifier hs-var">_alts</span></a></span></span><span>
</span><span id="line-525"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [NonVoid Id]
</span><a href="GHC.StgToCmm.Closure.html#assertNonVoidIds"><span class="hs-identifier hs-var">assertNonVoidIds</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061883"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-526"></span><span>
</span><span id="line-527"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#chooseReturnBndrs"><span class="hs-identifier hs-var">chooseReturnBndrs</span></a></span><span> </span><span id="local-6989586621681061880"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061880"><span class="hs-identifier hs-var">_bndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#MultiValAlt"><span class="hs-identifier hs-type">MultiValAlt</span></a></span><span> </span><span id="local-6989586621681061878"><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061878"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681061877"><span class="annot"><span class="annottext">[BinderP 'CodeGen]
</span><a href="#local-6989586621681061877"><span class="hs-identifier hs-var">ids</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CgStgExpr
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-528"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span class="hs-identifier">ids</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">lengthIs</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">n</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">n</span><span> </span><span class="hs-operator">$$</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">ids</span><span> </span><span class="hs-operator">$$</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">_bndr</span><span class="hs-special">)</span><span>
</span><span id="line-529"></span><span>    </span><span class="annot"><span class="annottext">[Id] -&gt; [NonVoid Id]
</span><a href="GHC.StgToCmm.Closure.html#assertNonVoidIds"><span class="hs-identifier hs-var">assertNonVoidIds</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
[BinderP 'CodeGen]
</span><a href="#local-6989586621681061877"><span class="hs-identifier hs-var">ids</span></a></span><span>     </span><span class="hs-comment">-- 'bndr' is not assigned!</span><span>
</span><span id="line-530"></span><span>
</span><span id="line-531"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#chooseReturnBndrs"><span class="hs-identifier hs-var">chooseReturnBndrs</span></a></span><span> </span><span id="local-6989586621681061872"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061872"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#AlgAlt"><span class="hs-identifier hs-type">AlgAlt</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681061870"><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061870"><span class="hs-identifier hs-var">_alts</span></a></span></span><span>
</span><span id="line-532"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [NonVoid Id]
</span><a href="GHC.StgToCmm.Closure.html#assertNonVoidIds"><span class="hs-identifier hs-var">assertNonVoidIds</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061872"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">]</span><span>  </span><span class="hs-comment">-- Only 'bndr' is assigned</span><span>
</span><span id="line-533"></span><span>
</span><span id="line-534"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#chooseReturnBndrs"><span class="hs-identifier hs-var">chooseReturnBndrs</span></a></span><span> </span><span id="local-6989586621681061869"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061869"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="annot"><span class="annottext">AltType
</span><a href="GHC.Stg.Syntax.html#PolyAlt"><span class="hs-identifier hs-var">PolyAlt</span></a></span><span> </span><span id="local-6989586621681061867"><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061867"><span class="hs-identifier hs-var">_alts</span></a></span></span><span>
</span><span id="line-535"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [NonVoid Id]
</span><a href="GHC.StgToCmm.Closure.html#assertNonVoidIds"><span class="hs-identifier hs-var">assertNonVoidIds</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061869"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">]</span><span>  </span><span class="hs-comment">-- Only 'bndr' is assigned</span><span>
</span><span id="line-536"></span><span>
</span><span id="line-537"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#chooseReturnBndrs"><span class="hs-identifier hs-var">chooseReturnBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">AltType
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; [NonVoid Id]
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;chooseReturnBndrs&quot;</span></span><span>
</span><span id="line-538"></span><span>                             </span><span class="hs-comment">-- MultiValAlt has only one alternative</span><span>
</span><span id="line-539"></span><span>
</span><span id="line-540"></span><span class="hs-comment">-------------------------------------</span><span>
</span><span id="line-541"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgAlts"><span class="hs-identifier hs-type">cgAlts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.StgToCmm.Expr.html#GcPlan"><span class="hs-identifier hs-type">GcPlan</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.StgToCmm.Monad.html#ReturnKind"><span class="hs-identifier hs-type">ReturnKind</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Closure.html#NonVoid"><span class="hs-identifier hs-type">NonVoid</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#AltType"><span class="hs-identifier hs-type">AltType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#CgStgAlt"><span class="hs-identifier hs-type">CgStgAlt</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-542"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#ReturnKind"><span class="hs-identifier hs-type">ReturnKind</span></a></span><span>
</span><span id="line-543"></span><span class="hs-comment">-- At this point the result of the case are in the binders</span><span>
</span><span id="line-544"></span><span id="cgAlts"><span class="annot"><span class="annottext">cgAlts :: (GcPlan, ReturnKind)
-&gt; NonVoid Id
-&gt; AltType
-&gt; [GenStgAlt 'CodeGen]
-&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgAlts"><span class="hs-identifier hs-var hs-var">cgAlts</span></a></span></span><span> </span><span id="local-6989586621681061866"><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
</span><a href="#local-6989586621681061866"><span class="hs-identifier hs-var">gc_plan</span></a></span></span><span> </span><span id="local-6989586621681061865"><span class="annot"><span class="annottext">NonVoid Id
</span><a href="#local-6989586621681061865"><span class="hs-identifier hs-var">_bndr</span></a></span></span><span> </span><span class="annot"><span class="annottext">AltType
</span><a href="GHC.Stg.Syntax.html#PolyAlt"><span class="hs-identifier hs-var">PolyAlt</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[BinderP 'CodeGen]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681061864"><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681061864"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-545"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(GcPlan, ReturnKind) -&gt; FCode ReturnKind -&gt; FCode ReturnKind
forall a. (GcPlan, ReturnKind) -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Expr.html#maybeAltHeapCheck"><span class="hs-identifier hs-var">maybeAltHeapCheck</span></a></span><span> </span><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
</span><a href="#local-6989586621681061866"><span class="hs-identifier hs-var">gc_plan</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CgStgExpr -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681061864"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-546"></span><span>
</span><span id="line-547"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgAlts"><span class="hs-identifier hs-var">cgAlts</span></a></span><span> </span><span id="local-6989586621681061862"><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
</span><a href="#local-6989586621681061862"><span class="hs-identifier hs-var">gc_plan</span></a></span></span><span> </span><span id="local-6989586621681061861"><span class="annot"><span class="annottext">NonVoid Id
</span><a href="#local-6989586621681061861"><span class="hs-identifier hs-var">_bndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#MultiValAlt"><span class="hs-identifier hs-type">MultiValAlt</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[BinderP 'CodeGen]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681061860"><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681061860"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-548"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(GcPlan, ReturnKind) -&gt; FCode ReturnKind -&gt; FCode ReturnKind
forall a. (GcPlan, ReturnKind) -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Expr.html#maybeAltHeapCheck"><span class="hs-identifier hs-var">maybeAltHeapCheck</span></a></span><span> </span><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
</span><a href="#local-6989586621681061862"><span class="hs-identifier hs-var">gc_plan</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CgStgExpr -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681061860"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-549"></span><span>        </span><span class="hs-comment">-- Here bndrs are *already* in scope, so don't rebind them</span><span>
</span><span id="line-550"></span><span>
</span><span id="line-551"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgAlts"><span class="hs-identifier hs-var">cgAlts</span></a></span><span> </span><span id="local-6989586621681061859"><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
</span><a href="#local-6989586621681061859"><span class="hs-identifier hs-var">gc_plan</span></a></span></span><span> </span><span id="local-6989586621681061858"><span class="annot"><span class="annottext">NonVoid Id
</span><a href="#local-6989586621681061858"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#PrimAlt"><span class="hs-identifier hs-type">PrimAlt</span></a></span><span> </span><span class="annot"><span class="annottext">PrimRep
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681061857"><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061857"><span class="hs-identifier hs-var">alts</span></a></span></span><span>
</span><span id="line-552"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681061856"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061856"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-553"></span><span>
</span><span id="line-554"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061855"><span class="annot"><span class="annottext">[(AltCon, CmmAGraphScoped)]
</span><a href="#local-6989586621681061855"><span class="hs-identifier hs-var">tagged_cmms</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
-&gt; NonVoid Id
-&gt; [GenStgAlt 'CodeGen]
-&gt; FCode [(AltCon, CmmAGraphScoped)]
</span><a href="GHC.StgToCmm.Expr.html#cgAltRhss"><span class="hs-identifier hs-var">cgAltRhss</span></a></span><span> </span><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
</span><a href="#local-6989586621681061859"><span class="hs-identifier hs-var">gc_plan</span></a></span><span> </span><span class="annot"><span class="annottext">NonVoid Id
</span><a href="#local-6989586621681061858"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061857"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-555"></span><span>
</span><span id="line-556"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681061853"><span class="annot"><span class="annottext">bndr_reg :: CmmReg
</span><a href="#local-6989586621681061853"><span class="hs-identifier hs-var hs-var">bndr_reg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; NonVoid Id -&gt; LocalReg
</span><a href="GHC.StgToCmm.Env.html#idToReg"><span class="hs-identifier hs-var">idToReg</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061856"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">NonVoid Id
</span><a href="#local-6989586621681061858"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-557"></span><span>              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><a href="GHC.Core.html#DEFAULT"><span class="hs-identifier hs-var">DEFAULT</span></a></span><span class="hs-special">,</span><span id="local-6989586621681061852"><span class="annot"><span class="annottext">CmmAGraphScoped
</span><a href="#local-6989586621681061852"><span class="hs-identifier hs-var">deflt</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(AltCon, CmmAGraphScoped)] -&gt; (AltCon, CmmAGraphScoped)
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[(AltCon, CmmAGraphScoped)]
</span><a href="#local-6989586621681061855"><span class="hs-identifier hs-var">tagged_cmms</span></a></span><span>
</span><span id="line-558"></span><span>                </span><span class="hs-comment">-- PrimAlts always have a DEFAULT case</span><span>
</span><span id="line-559"></span><span>                </span><span class="hs-comment">-- and it always comes first</span><span>
</span><span id="line-560"></span><span>
</span><span id="line-561"></span><span>              </span><span id="local-6989586621681061850"><span class="annot"><span class="annottext">tagged_cmms' :: [(Literal, CmmAGraphScoped)]
</span><a href="#local-6989586621681061850"><span class="hs-identifier hs-var hs-var">tagged_cmms'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621681061849"><span class="hs-identifier hs-var">lit</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CmmAGraphScoped
</span><a href="#local-6989586621681061848"><span class="hs-identifier hs-var">code</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-562"></span><span>                             </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#LitAlt"><span class="hs-identifier hs-type">LitAlt</span></a></span><span> </span><span id="local-6989586621681061849"><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621681061849"><span class="hs-identifier hs-var">lit</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681061848"><span class="annot"><span class="annottext">CmmAGraphScoped
</span><a href="#local-6989586621681061848"><span class="hs-identifier hs-var">code</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(AltCon, CmmAGraphScoped)]
</span><a href="#local-6989586621681061855"><span class="hs-identifier hs-var">tagged_cmms</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-563"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CmmExpr
-&gt; [(Literal, CmmAGraphScoped)] -&gt; CmmAGraphScoped -&gt; FCode ()
</span><a href="GHC.StgToCmm.Utils.html#emitCmmLitSwitch"><span class="hs-identifier hs-var">emitCmmLitSwitch</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681061853"><span class="hs-identifier hs-var">bndr_reg</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Literal, CmmAGraphScoped)]
</span><a href="#local-6989586621681061850"><span class="hs-identifier hs-var">tagged_cmms'</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraphScoped
</span><a href="#local-6989586621681061852"><span class="hs-identifier hs-var">deflt</span></a></span><span>
</span><span id="line-564"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">ReturnKind -&gt; FCode ReturnKind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ReturnKind
</span><a href="GHC.StgToCmm.Monad.html#AssignedDirectly"><span class="hs-identifier hs-var">AssignedDirectly</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-565"></span><span>
</span><span id="line-566"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgAlts"><span class="hs-identifier hs-var">cgAlts</span></a></span><span> </span><span id="local-6989586621681061845"><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
</span><a href="#local-6989586621681061845"><span class="hs-identifier hs-var">gc_plan</span></a></span></span><span> </span><span id="local-6989586621681061844"><span class="annot"><span class="annottext">NonVoid Id
</span><a href="#local-6989586621681061844"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#AlgAlt"><span class="hs-identifier hs-type">AlgAlt</span></a></span><span> </span><span id="local-6989586621681061843"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681061843"><span class="hs-identifier hs-var">tycon</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681061842"><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061842"><span class="hs-identifier hs-var">alts</span></a></span></span><span>
</span><span id="line-567"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681061841"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061841"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-568"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061840"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061840"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-569"></span><span>
</span><span id="line-570"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681061839"><span class="annot"><span class="annottext">Maybe CmmAGraphScoped
</span><a href="#local-6989586621681061839"><span class="hs-identifier hs-var">mb_deflt</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681061838"><span class="annot"><span class="annottext">[(RepArity, CmmAGraphScoped)]
</span><a href="#local-6989586621681061838"><span class="hs-identifier hs-var">branches</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
-&gt; NonVoid Id
-&gt; [GenStgAlt 'CodeGen]
-&gt; FCode (Maybe CmmAGraphScoped, [(RepArity, CmmAGraphScoped)])
</span><a href="GHC.StgToCmm.Expr.html#cgAlgAltRhss"><span class="hs-identifier hs-var">cgAlgAltRhss</span></a></span><span> </span><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
</span><a href="#local-6989586621681061845"><span class="hs-identifier hs-var">gc_plan</span></a></span><span> </span><span class="annot"><span class="annottext">NonVoid Id
</span><a href="#local-6989586621681061844"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061842"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-571"></span><span>
</span><span id="line-572"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621681061836"><span class="annot"><span class="annottext">fam_sz :: RepArity
</span><a href="#local-6989586621681061836"><span class="hs-identifier hs-var hs-var">fam_sz</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; RepArity
</span><a href="GHC.Core.TyCon.html#tyConFamilySize"><span class="hs-identifier hs-var">tyConFamilySize</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681061843"><span class="hs-identifier hs-var">tycon</span></a></span><span>
</span><span id="line-573"></span><span>              </span><span class="hs-glyph">!</span><span id="local-6989586621681061834"><span class="annot"><span class="annottext">bndr_reg :: CmmReg
</span><a href="#local-6989586621681061834"><span class="hs-identifier hs-var hs-var">bndr_reg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; NonVoid Id -&gt; LocalReg
</span><a href="GHC.StgToCmm.Env.html#idToReg"><span class="hs-identifier hs-var">idToReg</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061840"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">NonVoid Id
</span><a href="#local-6989586621681061844"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-574"></span><span>              </span><span class="hs-glyph">!</span><span id="local-6989586621681061833"><span class="annot"><span class="annottext">ptag_expr :: CmmExpr
</span><a href="#local-6989586621681061833"><span class="hs-identifier hs-var hs-var">ptag_expr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmConstrTag1"><span class="hs-identifier hs-var">cmmConstrTag1</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061841"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681061834"><span class="hs-identifier hs-var">bndr_reg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-575"></span><span>              </span><span class="hs-glyph">!</span><span id="local-6989586621681061826"><span class="annot"><span class="annottext">branches' :: [(RepArity, CmmAGraphScoped)]
</span><a href="#local-6989586621681061826"><span class="hs-identifier hs-var hs-var">branches'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(RepArity -&gt; RepArity)
-&gt; (RepArity, CmmAGraphScoped) -&gt; (RepArity, CmmAGraphScoped)
forall (a :: * -&gt; * -&gt; *) b c d.
Arrow a =&gt;
a b c -&gt; a (b, d) (c, d)
</span><a href="../../base/src/Control.Arrow.html#first"><span class="hs-identifier hs-var">first</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity -&gt; RepArity
forall a. Enum a =&gt; a -&gt; a
</span><a href="../../base/src/GHC.Enum.html#succ"><span class="hs-identifier hs-var">succ</span></a></span><span> </span><span class="annot"><span class="annottext">((RepArity, CmmAGraphScoped) -&gt; (RepArity, CmmAGraphScoped))
-&gt; [(RepArity, CmmAGraphScoped)] -&gt; [(RepArity, CmmAGraphScoped)]
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[(RepArity, CmmAGraphScoped)]
</span><a href="#local-6989586621681061838"><span class="hs-identifier hs-var">branches</span></a></span><span>
</span><span id="line-576"></span><span>              </span><span class="hs-glyph">!</span><span id="local-6989586621681061823"><span class="annot"><span class="annottext">maxpt :: RepArity
</span><a href="#local-6989586621681061823"><span class="hs-identifier hs-var hs-var">maxpt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; RepArity
</span><a href="GHC.Driver.Session.html#mAX_PTR_TAG"><span class="hs-identifier hs-var">mAX_PTR_TAG</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061841"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-577"></span><span>              </span><span class="hs-special">(</span><span class="hs-glyph">!</span><span id="local-6989586621681061821"><span class="annot"><span class="annottext">[(RepArity, CmmAGraphScoped)]
</span><a href="#local-6989586621681061821"><span class="hs-identifier hs-var">via_ptr</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621681061820"><span class="annot"><span class="annottext">[(RepArity, CmmAGraphScoped)]
</span><a href="#local-6989586621681061820"><span class="hs-identifier hs-var">via_info</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((RepArity, CmmAGraphScoped) -&gt; Bool)
-&gt; [(RepArity, CmmAGraphScoped)]
-&gt; ([(RepArity, CmmAGraphScoped)], [(RepArity, CmmAGraphScoped)])
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/Data.OldList.html#partition"><span class="hs-identifier hs-var">partition</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">RepArity -&gt; RepArity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061823"><span class="hs-identifier hs-var">maxpt</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(RepArity -&gt; Bool)
-&gt; ((RepArity, CmmAGraphScoped) -&gt; RepArity)
-&gt; (RepArity, CmmAGraphScoped)
-&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(RepArity, CmmAGraphScoped) -&gt; RepArity
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(RepArity, CmmAGraphScoped)]
</span><a href="#local-6989586621681061826"><span class="hs-identifier hs-var">branches'</span></a></span><span>
</span><span id="line-578"></span><span>              </span><span class="hs-glyph">!</span><span id="local-6989586621681061817"><span class="annot"><span class="annottext">small :: Bool
</span><a href="#local-6989586621681061817"><span class="hs-identifier hs-var hs-var">small</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; RepArity -&gt; Bool
</span><a href="GHC.StgToCmm.Closure.html#isSmallFamily"><span class="hs-identifier hs-var">isSmallFamily</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061841"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061836"><span class="hs-identifier hs-var">fam_sz</span></a></span><span>
</span><span id="line-579"></span><span>
</span><span id="line-580"></span><span>                </span><span class="hs-comment">-- Is the constructor tag in the node reg?</span><span>
</span><span id="line-581"></span><span>                </span><span class="hs-comment">-- See Note [Tagging big families]</span><span>
</span><span id="line-582"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681061817"><span class="hs-identifier hs-var">small</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">[(RepArity, CmmAGraphScoped)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[(RepArity, CmmAGraphScoped)]
</span><a href="#local-6989586621681061820"><span class="hs-identifier hs-var">via_info</span></a></span><span>
</span><span id="line-583"></span><span>           </span><span class="hs-keyword">then</span><span> </span><span class="hs-comment">-- Yes, bndr_reg has constructor tag in ls bits</span><span>
</span><span id="line-584"></span><span>               </span><span class="annot"><span class="annottext">CmmExpr
-&gt; [(RepArity, CmmAGraphScoped)]
-&gt; Maybe CmmAGraphScoped
-&gt; RepArity
-&gt; RepArity
-&gt; FCode ()
</span><a href="GHC.StgToCmm.Utils.html#emitSwitch"><span class="hs-identifier hs-var">emitSwitch</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681061833"><span class="hs-identifier hs-var">ptag_expr</span></a></span><span> </span><span class="annot"><span class="annottext">[(RepArity, CmmAGraphScoped)]
</span><a href="#local-6989586621681061826"><span class="hs-identifier hs-var">branches'</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe CmmAGraphScoped
</span><a href="#local-6989586621681061839"><span class="hs-identifier hs-var">mb_deflt</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><span class="hs-number">1</span></span><span>
</span><span id="line-585"></span><span>                 </span><span class="hs-special">(</span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681061817"><span class="hs-identifier hs-var">small</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061836"><span class="hs-identifier hs-var">fam_sz</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061823"><span class="hs-identifier hs-var">maxpt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-586"></span><span>
</span><span id="line-587"></span><span>           </span><span class="hs-keyword">else</span><span> </span><span class="hs-comment">-- No, the get exact tag from info table when mAX_PTR_TAG</span><span>
</span><span id="line-588"></span><span>                </span><span class="hs-comment">-- See Note [Double switching for big families]</span><span>
</span><span id="line-589"></span><span>              </span><span class="hs-keyword">do</span><span>
</span><span id="line-590"></span><span>                </span><span class="hs-keyword">let</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621681061812"><span class="annot"><span class="annottext">untagged_ptr :: CmmExpr
</span><a href="#local-6989586621681061812"><span class="hs-identifier hs-var hs-var">untagged_ptr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmUntag"><span class="hs-identifier hs-var">cmmUntag</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061841"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681061834"><span class="hs-identifier hs-var">bndr_reg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-591"></span><span>                    </span><span class="hs-glyph">!</span><span id="local-6989586621681061811"><span class="annot"><span class="annottext">itag_expr :: CmmExpr
</span><a href="#local-6989586621681061811"><span class="hs-identifier hs-var hs-var">itag_expr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.Cmm.Info.html#getConstrTag"><span class="hs-identifier hs-var">getConstrTag</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061841"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681061812"><span class="hs-identifier hs-var">untagged_ptr</span></a></span><span>
</span><span id="line-592"></span><span>                    </span><span class="hs-glyph">!</span><span id="local-6989586621681061807"><span class="annot"><span class="annottext">info0 :: [(RepArity, CmmAGraphScoped)]
</span><a href="#local-6989586621681061807"><span class="hs-identifier hs-var hs-var">info0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(RepArity -&gt; RepArity)
-&gt; (RepArity, CmmAGraphScoped) -&gt; (RepArity, CmmAGraphScoped)
forall (a :: * -&gt; * -&gt; *) b c d.
Arrow a =&gt;
a b c -&gt; a (b, d) (c, d)
</span><a href="../../base/src/Control.Arrow.html#first"><span class="hs-identifier hs-var">first</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity -&gt; RepArity
forall a. Enum a =&gt; a -&gt; a
</span><a href="../../base/src/GHC.Enum.html#pred"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="annot"><span class="annottext">((RepArity, CmmAGraphScoped) -&gt; (RepArity, CmmAGraphScoped))
-&gt; [(RepArity, CmmAGraphScoped)] -&gt; [(RepArity, CmmAGraphScoped)]
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[(RepArity, CmmAGraphScoped)]
</span><a href="#local-6989586621681061820"><span class="hs-identifier hs-var">via_info</span></a></span><span>
</span><span id="line-593"></span><span>                </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">[(RepArity, CmmAGraphScoped)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[(RepArity, CmmAGraphScoped)]
</span><a href="#local-6989586621681061821"><span class="hs-identifier hs-var">via_ptr</span></a></span><span> </span><span class="hs-keyword">then</span><span>
</span><span id="line-594"></span><span>                  </span><span class="annot"><span class="annottext">CmmExpr
-&gt; [(RepArity, CmmAGraphScoped)]
-&gt; Maybe CmmAGraphScoped
-&gt; RepArity
-&gt; RepArity
-&gt; FCode ()
</span><a href="GHC.StgToCmm.Utils.html#emitSwitch"><span class="hs-identifier hs-var">emitSwitch</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681061811"><span class="hs-identifier hs-var">itag_expr</span></a></span><span> </span><span class="annot"><span class="annottext">[(RepArity, CmmAGraphScoped)]
</span><a href="#local-6989586621681061807"><span class="hs-identifier hs-var">info0</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe CmmAGraphScoped
</span><a href="#local-6989586621681061839"><span class="hs-identifier hs-var">mb_deflt</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><span class="hs-number">0</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061836"><span class="hs-identifier hs-var">fam_sz</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity -&gt; RepArity -&gt; RepArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-595"></span><span>                </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-596"></span><span>                  </span><span id="local-6989586621681061805"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061805"><span class="hs-identifier hs-var">infos_lbl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode BlockId
forall (m :: * -&gt; *). MonadUnique m =&gt; m BlockId
</span><a href="GHC.Cmm.BlockId.html#newBlockId"><span class="hs-identifier hs-var">newBlockId</span></a></span><span>
</span><span id="line-597"></span><span>                  </span><span id="local-6989586621681061804"><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681061804"><span class="hs-identifier hs-var">infos_scp</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode CmmTickScope
</span><a href="GHC.StgToCmm.Monad.html#getTickScope"><span class="hs-identifier hs-var">getTickScope</span></a></span><span>
</span><span id="line-598"></span><span>
</span><span id="line-599"></span><span>                  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681061802"><span class="annot"><span class="annottext">spillover :: (RepArity, CmmAGraphScoped)
</span><a href="#local-6989586621681061802"><span class="hs-identifier hs-var hs-var">spillover</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061823"><span class="hs-identifier hs-var">maxpt</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkBranch"><span class="hs-identifier hs-var">mkBranch</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061805"><span class="hs-identifier hs-var">infos_lbl</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681061804"><span class="hs-identifier hs-var">infos_scp</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-600"></span><span>
</span><span id="line-601"></span><span>                  </span><span class="hs-special">(</span><span id="local-6989586621681061801"><span class="annot"><span class="annottext">Maybe CmmAGraphScoped
</span><a href="#local-6989586621681061801"><span class="hs-identifier hs-var">mb_shared_deflt</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681061800"><span class="annot"><span class="annottext">Maybe CmmAGraphScoped
</span><a href="#local-6989586621681061800"><span class="hs-identifier hs-var">mb_shared_branch</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe CmmAGraphScoped
</span><a href="#local-6989586621681061839"><span class="hs-identifier hs-var">mb_deflt</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-602"></span><span>                      </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681061799"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681061799"><span class="hs-identifier hs-var">stmts</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681061798"><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681061798"><span class="hs-identifier hs-var">scp</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-603"></span><span>                          </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681061797"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061797"><span class="hs-identifier hs-var">lbl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode BlockId
forall (m :: * -&gt; *). MonadUnique m =&gt; m BlockId
</span><a href="GHC.Cmm.BlockId.html#newBlockId"><span class="hs-identifier hs-var">newBlockId</span></a></span><span>
</span><span id="line-604"></span><span>                             </span><span class="annot"><span class="annottext">(Maybe CmmAGraphScoped, Maybe CmmAGraphScoped)
-&gt; FCode (Maybe CmmAGraphScoped, Maybe CmmAGraphScoped)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">CmmAGraphScoped -&gt; Maybe CmmAGraphScoped
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; CmmTickScope -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkLabel"><span class="hs-identifier hs-var">mkLabel</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061797"><span class="hs-identifier hs-var">lbl</span></a></span><span> </span><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681061798"><span class="hs-identifier hs-var">scp</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; CmmAGraph -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681061799"><span class="hs-identifier hs-var">stmts</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681061798"><span class="hs-identifier hs-var">scp</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-605"></span><span>                                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmAGraphScoped -&gt; Maybe CmmAGraphScoped
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkBranch"><span class="hs-identifier hs-var">mkBranch</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061797"><span class="hs-identifier hs-var">lbl</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681061798"><span class="hs-identifier hs-var">scp</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-606"></span><span>                      </span><span class="annot"><span class="annottext">Maybe CmmAGraphScoped
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Maybe CmmAGraphScoped, Maybe CmmAGraphScoped)
-&gt; FCode (Maybe CmmAGraphScoped, Maybe CmmAGraphScoped)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe CmmAGraphScoped
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe CmmAGraphScoped
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-607"></span><span>                  </span><span class="hs-comment">-- Switch on pointer tag</span><span>
</span><span id="line-608"></span><span>                  </span><span class="annot"><span class="annottext">CmmExpr
-&gt; [(RepArity, CmmAGraphScoped)]
-&gt; Maybe CmmAGraphScoped
-&gt; RepArity
-&gt; RepArity
-&gt; FCode ()
</span><a href="GHC.StgToCmm.Utils.html#emitSwitch"><span class="hs-identifier hs-var">emitSwitch</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681061833"><span class="hs-identifier hs-var">ptag_expr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(RepArity, CmmAGraphScoped)
</span><a href="#local-6989586621681061802"><span class="hs-identifier hs-var">spillover</span></a></span><span> </span><span class="annot"><span class="annottext">(RepArity, CmmAGraphScoped)
-&gt; [(RepArity, CmmAGraphScoped)] -&gt; [(RepArity, CmmAGraphScoped)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[(RepArity, CmmAGraphScoped)]
</span><a href="#local-6989586621681061821"><span class="hs-identifier hs-var">via_ptr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe CmmAGraphScoped
</span><a href="#local-6989586621681061801"><span class="hs-identifier hs-var">mb_shared_deflt</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061823"><span class="hs-identifier hs-var">maxpt</span></a></span><span>
</span><span id="line-609"></span><span>                  </span><span id="local-6989586621681061795"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061795"><span class="hs-identifier hs-var">join_lbl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode BlockId
forall (m :: * -&gt; *). MonadUnique m =&gt; m BlockId
</span><a href="GHC.Cmm.BlockId.html#newBlockId"><span class="hs-identifier hs-var">newBlockId</span></a></span><span>
</span><span id="line-610"></span><span>                  </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkBranch"><span class="hs-identifier hs-var">mkBranch</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061795"><span class="hs-identifier hs-var">join_lbl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-611"></span><span>                  </span><span class="hs-comment">-- Switch on info table tag</span><span>
</span><span id="line-612"></span><span>                  </span><span class="annot"><span class="annottext">BlockId -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitLabel"><span class="hs-identifier hs-var">emitLabel</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061805"><span class="hs-identifier hs-var">infos_lbl</span></a></span><span>
</span><span id="line-613"></span><span>                  </span><span class="annot"><span class="annottext">CmmExpr
-&gt; [(RepArity, CmmAGraphScoped)]
-&gt; Maybe CmmAGraphScoped
-&gt; RepArity
-&gt; RepArity
-&gt; FCode ()
</span><a href="GHC.StgToCmm.Utils.html#emitSwitch"><span class="hs-identifier hs-var">emitSwitch</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681061811"><span class="hs-identifier hs-var">itag_expr</span></a></span><span> </span><span class="annot"><span class="annottext">[(RepArity, CmmAGraphScoped)]
</span><a href="#local-6989586621681061807"><span class="hs-identifier hs-var">info0</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe CmmAGraphScoped
</span><a href="#local-6989586621681061800"><span class="hs-identifier hs-var">mb_shared_branch</span></a></span><span>
</span><span id="line-614"></span><span>                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061823"><span class="hs-identifier hs-var">maxpt</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity -&gt; RepArity -&gt; RepArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061836"><span class="hs-identifier hs-var">fam_sz</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity -&gt; RepArity -&gt; RepArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-615"></span><span>                  </span><span class="annot"><span class="annottext">BlockId -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitLabel"><span class="hs-identifier hs-var">emitLabel</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061795"><span class="hs-identifier hs-var">join_lbl</span></a></span><span>
</span><span id="line-616"></span><span>
</span><span id="line-617"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">ReturnKind -&gt; FCode ReturnKind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ReturnKind
</span><a href="GHC.StgToCmm.Monad.html#AssignedDirectly"><span class="hs-identifier hs-var">AssignedDirectly</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-618"></span><span>
</span><span id="line-619"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgAlts"><span class="hs-identifier hs-var">cgAlts</span></a></span><span> </span><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">NonVoid Id
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">AltType
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; FCode ReturnKind
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cgAlts&quot;</span></span><span>
</span><span id="line-620"></span><span>        </span><span class="hs-comment">-- UbxTupAlt and PolyAlt have only one alternative</span><span>
</span><span id="line-621"></span><span>
</span><span id="line-622"></span><span class="hs-comment">-- Note [Double switching for big families]</span><span>
</span><span id="line-623"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-624"></span><span class="hs-comment">--</span><span>
</span><span id="line-625"></span><span class="hs-comment">-- An algebraic data type can have a n &gt;= 0 summands</span><span>
</span><span id="line-626"></span><span class="hs-comment">-- (or alternatives), which are identified (labeled) by</span><span>
</span><span id="line-627"></span><span class="hs-comment">-- constructors. In memory they are kept apart by tags</span><span>
</span><span id="line-628"></span><span class="hs-comment">-- (see Note [Data constructor dynamic tags] in GHC.StgToCmm.Closure).</span><span>
</span><span id="line-629"></span><span class="hs-comment">-- Due to the characteristics of the platform that</span><span>
</span><span id="line-630"></span><span class="hs-comment">-- contribute to the alignment of memory objects, there</span><span>
</span><span id="line-631"></span><span class="hs-comment">-- is a natural limit of information about constructors</span><span>
</span><span id="line-632"></span><span class="hs-comment">-- that can be encoded in the pointer tag. When the mapping</span><span>
</span><span id="line-633"></span><span class="hs-comment">-- of constructors to the pointer tag range 1..mAX_PTR_TAG</span><span>
</span><span id="line-634"></span><span class="hs-comment">-- is not injective, then we have a &quot;big data type&quot;, also</span><span>
</span><span id="line-635"></span><span class="hs-comment">-- called a &quot;big (constructor) family&quot; in the literature.</span><span>
</span><span id="line-636"></span><span class="hs-comment">-- Constructor tags residing in the info table are injective,</span><span>
</span><span id="line-637"></span><span class="hs-comment">-- but considerably more expensive to obtain, due to additional</span><span>
</span><span id="line-638"></span><span class="hs-comment">-- memory access(es).</span><span>
</span><span id="line-639"></span><span class="hs-comment">--</span><span>
</span><span id="line-640"></span><span class="hs-comment">-- When doing case analysis on a value of a &quot;big data type&quot;</span><span>
</span><span id="line-641"></span><span class="hs-comment">-- we need two nested switch statements to make up for the lack</span><span>
</span><span id="line-642"></span><span class="hs-comment">-- of injectivity of pointer tagging, also taking the info</span><span>
</span><span id="line-643"></span><span class="hs-comment">-- table tag into account. The exact mechanism is described next.</span><span>
</span><span id="line-644"></span><span class="hs-comment">--</span><span>
</span><span id="line-645"></span><span class="hs-comment">-- In the general case, switching on big family alternatives</span><span>
</span><span id="line-646"></span><span class="hs-comment">-- is done by two nested switch statements. According to</span><span>
</span><span id="line-647"></span><span class="hs-comment">-- Note [Tagging big families], the outer switch</span><span>
</span><span id="line-648"></span><span class="hs-comment">-- looks at the pointer tag and the inner dereferences the</span><span>
</span><span id="line-649"></span><span class="hs-comment">-- pointer and switches on the info table tag.</span><span>
</span><span id="line-650"></span><span class="hs-comment">--</span><span>
</span><span id="line-651"></span><span class="hs-comment">-- We can handle a simple case first, namely when none</span><span>
</span><span id="line-652"></span><span class="hs-comment">-- of the case alternatives mention a constructor having</span><span>
</span><span id="line-653"></span><span class="hs-comment">-- a pointer tag of 1..mAX_PTR_TAG-1. In this case we</span><span>
</span><span id="line-654"></span><span class="hs-comment">-- simply emit a switch on the info table tag.</span><span>
</span><span id="line-655"></span><span class="hs-comment">-- Note that the other simple case is when all mentioned</span><span>
</span><span id="line-656"></span><span class="hs-comment">-- alternatives lie in 1..mAX_PTR_TAG-1, in which case we can</span><span>
</span><span id="line-657"></span><span class="hs-comment">-- switch on the ptr tag only, just like in the small family case.</span><span>
</span><span id="line-658"></span><span class="hs-comment">--</span><span>
</span><span id="line-659"></span><span class="hs-comment">-- There is a single intricacy with a nested switch:</span><span>
</span><span id="line-660"></span><span class="hs-comment">-- Both should branch to the same default alternative, and as such</span><span>
</span><span id="line-661"></span><span class="hs-comment">-- avoid duplicate codegen of potentially heavy code. The outer</span><span>
</span><span id="line-662"></span><span class="hs-comment">-- switch generates the actual code with a prepended fresh label,</span><span>
</span><span id="line-663"></span><span class="hs-comment">-- while the inner one only generates a jump to that label.</span><span>
</span><span id="line-664"></span><span class="hs-comment">--</span><span>
</span><span id="line-665"></span><span class="hs-comment">-- For example, let's assume a 64-bit architecture, so that all</span><span>
</span><span id="line-666"></span><span class="hs-comment">-- heap objects are 8-byte aligned, and hence the address of a</span><span>
</span><span id="line-667"></span><span class="hs-comment">-- heap object ends in `000` (three zero bits).</span><span>
</span><span id="line-668"></span><span class="hs-comment">--</span><span>
</span><span id="line-669"></span><span class="hs-comment">-- Then consider the following data type</span><span>
</span><span id="line-670"></span><span class="hs-comment">--</span><span>
</span><span id="line-671"></span><span class="hs-comment">--   &gt; data Big = T0 | T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8</span><span>
</span><span id="line-672"></span><span class="hs-comment">--   Ptr tag:      1    2    3    4    5    6    7    7    7</span><span>
</span><span id="line-673"></span><span class="hs-comment">--   As bits:    001  010  011  100  101  110  111  111  111</span><span>
</span><span id="line-674"></span><span class="hs-comment">--   Info pointer tag (zero based):</span><span>
</span><span id="line-675"></span><span class="hs-comment">--                 0    1    2    3    4    5    6    7    8</span><span>
</span><span id="line-676"></span><span class="hs-comment">--</span><span>
</span><span id="line-677"></span><span class="hs-comment">-- Then     \case T2 -&gt; True; T8 -&gt; True; _ -&gt; False</span><span>
</span><span id="line-678"></span><span class="hs-comment">-- will result in following code (slightly cleaned-up and</span><span>
</span><span id="line-679"></span><span class="hs-comment">-- commented -ddump-cmm-from-stg):</span><span>
</span><span id="line-680"></span><span class="hs-comment">{-
           R1 = _sqI::P64;  -- scrutinee
           if (R1 &amp; 7 != 0) goto cqO; else goto cqP;
       cqP: // global       -- enter
           call (I64[R1])(R1) returns to cqO, args: 8, res: 8, upd: 8;
       cqO: // global       -- already WHNF
           _sqJ::P64 = R1;
           _cqX::P64 = _sqJ::P64 &amp; 7;  -- extract pointer tag
           switch [1 .. 7] _cqX::P64 {
               case 3 : goto cqW;
               case 7 : goto cqR;
               default: {goto cqS;}
           }
       cqR: // global
           _cr2 = I32[I64[_sqJ::P64 &amp; (-8)] - 4]; -- tag from info pointer
           switch [6 .. 8] _cr2::I64 {
               case 8 : goto cr1;
               default: {goto cr0;}
           }
       cr1: // global
           R1 = GHC.Types.True_closure+2;
           call (P64[(old + 8)])(R1) args: 8, res: 0, upd: 8;
       cr0: // global     -- technically necessary label
           goto cqS;
       cqW: // global
           R1 = GHC.Types.True_closure+2;
           call (P64[(old + 8)])(R1) args: 8, res: 0, upd: 8;
       cqS: // global
           R1 = GHC.Types.False_closure+1;
           call (P64[(old + 8)])(R1) args: 8, res: 0, upd: 8;
-}</span><span>
</span><span id="line-711"></span><span class="hs-comment">--</span><span>
</span><span id="line-712"></span><span class="hs-comment">-- For 32-bit systems we only have 2 tag bits in the pointers at our disposal,</span><span>
</span><span id="line-713"></span><span class="hs-comment">-- so the performance win is dubious, especially in face of the increased code</span><span>
</span><span id="line-714"></span><span class="hs-comment">-- size due to double switching. But we can take the viewpoint that 32-bit</span><span>
</span><span id="line-715"></span><span class="hs-comment">-- architectures are not relevant for performance any more, so this can be</span><span>
</span><span id="line-716"></span><span class="hs-comment">-- considered as moot.</span><span>
</span><span id="line-717"></span><span>
</span><span id="line-718"></span><span>
</span><span id="line-719"></span><span class="hs-comment">-- Note [alg-alt heap check]</span><span>
</span><span id="line-720"></span><span class="hs-comment">--</span><span>
</span><span id="line-721"></span><span class="hs-comment">-- In an algebraic case with more than one alternative, we will have</span><span>
</span><span id="line-722"></span><span class="hs-comment">-- code like</span><span>
</span><span id="line-723"></span><span class="hs-comment">--</span><span>
</span><span id="line-724"></span><span class="hs-comment">-- L0:</span><span>
</span><span id="line-725"></span><span class="hs-comment">--   x = R1</span><span>
</span><span id="line-726"></span><span class="hs-comment">--   goto L1</span><span>
</span><span id="line-727"></span><span class="hs-comment">-- L1:</span><span>
</span><span id="line-728"></span><span class="hs-comment">--   if (x &amp; 7 &gt;= 2) then goto L2 else goto L3</span><span>
</span><span id="line-729"></span><span class="hs-comment">-- L2:</span><span>
</span><span id="line-730"></span><span class="hs-comment">--   Hp = Hp + 16</span><span>
</span><span id="line-731"></span><span class="hs-comment">--   if (Hp &gt; HpLim) then goto L4</span><span>
</span><span id="line-732"></span><span class="hs-comment">--   ...</span><span>
</span><span id="line-733"></span><span class="hs-comment">-- L4:</span><span>
</span><span id="line-734"></span><span class="hs-comment">--   call gc() returns to L5</span><span>
</span><span id="line-735"></span><span class="hs-comment">-- L5:</span><span>
</span><span id="line-736"></span><span class="hs-comment">--   x = R1</span><span>
</span><span id="line-737"></span><span class="hs-comment">--   goto L1</span><span>
</span><span id="line-738"></span><span>
</span><span id="line-739"></span><span>
</span><span id="line-740"></span><span class="hs-comment">-- Note [Tagging big families]</span><span>
</span><span id="line-741"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-742"></span><span class="hs-comment">--</span><span>
</span><span id="line-743"></span><span class="hs-comment">-- Both the big and the small constructor families are tagged,</span><span>
</span><span id="line-744"></span><span class="hs-comment">-- that is, greater unions which overflow the tag space of TAG_BITS</span><span>
</span><span id="line-745"></span><span class="hs-comment">-- (i.e. 3 on 32 resp. 7 constructors on 64 bit archs).</span><span>
</span><span id="line-746"></span><span class="hs-comment">--</span><span>
</span><span id="line-747"></span><span class="hs-comment">-- For example, let's assume a 64-bit architecture, so that all</span><span>
</span><span id="line-748"></span><span class="hs-comment">-- heap objects are 8-byte aligned, and hence the address of a</span><span>
</span><span id="line-749"></span><span class="hs-comment">-- heap object ends in `000` (three zero bits).  Then consider</span><span>
</span><span id="line-750"></span><span class="hs-comment">-- &gt; data Maybe a = Nothing | Just a</span><span>
</span><span id="line-751"></span><span class="hs-comment">-- &gt; data Day a = Mon | Tue | Wed | Thu | Fri | Sat | Sun</span><span>
</span><span id="line-752"></span><span class="hs-comment">-- &gt; data Grade = G1 | G2 | G3 | G4 | G5 | G6 | G7 | G8 | G9 | G10</span><span>
</span><span id="line-753"></span><span class="hs-comment">--</span><span>
</span><span id="line-754"></span><span class="hs-comment">-- Since `Grade` has more than 7 constructors, it counts as a</span><span>
</span><span id="line-755"></span><span class="hs-comment">-- &quot;big data type&quot; (also referred to as &quot;big constructor family&quot; in papers).</span><span>
</span><span id="line-756"></span><span class="hs-comment">-- On the other hand, `Maybe` and `Day` have 7 constructors or fewer, so they</span><span>
</span><span id="line-757"></span><span class="hs-comment">-- are &quot;small data types&quot;.</span><span>
</span><span id="line-758"></span><span class="hs-comment">--</span><span>
</span><span id="line-759"></span><span class="hs-comment">-- Then</span><span>
</span><span id="line-760"></span><span class="hs-comment">--   * A pointer to an unevaluated thunk of type `Maybe Int`, `Day` or `Grade` will end in `000`</span><span>
</span><span id="line-761"></span><span class="hs-comment">--   * A tagged pointer to a `Nothing`, `Mon` or `G1` will end in `001`</span><span>
</span><span id="line-762"></span><span class="hs-comment">--   * A tagged pointer to a `Just x`, `Tue` or `G2`  will end in `010`</span><span>
</span><span id="line-763"></span><span class="hs-comment">--   * A tagged pointer to `Wed` or `G3` will end in `011`</span><span>
</span><span id="line-764"></span><span class="hs-comment">--       ...</span><span>
</span><span id="line-765"></span><span class="hs-comment">--   * A tagged pointer to `Sat` or `G6` will end in `110`</span><span>
</span><span id="line-766"></span><span class="hs-comment">--   * A tagged pointer to `Sun` or `G7` or `G8` or `G9` or `G10` will end in `111`</span><span>
</span><span id="line-767"></span><span class="hs-comment">--</span><span>
</span><span id="line-768"></span><span class="hs-comment">-- For big families we employ a mildly clever way of combining pointer and</span><span>
</span><span id="line-769"></span><span class="hs-comment">-- info-table tagging. We use 1..MAX_PTR_TAG-1 as pointer-resident tags where</span><span>
</span><span id="line-770"></span><span class="hs-comment">-- the tags in the pointer and the info table are in a one-to-one</span><span>
</span><span id="line-771"></span><span class="hs-comment">-- relation, whereas tag MAX_PTR_TAG is used as &quot;spill over&quot;, signifying</span><span>
</span><span id="line-772"></span><span class="hs-comment">-- we have to fall back and get the precise constructor tag from the</span><span>
</span><span id="line-773"></span><span class="hs-comment">-- info-table.</span><span>
</span><span id="line-774"></span><span class="hs-comment">--</span><span>
</span><span id="line-775"></span><span class="hs-comment">-- Consequently we now cascade switches, because we have to check</span><span>
</span><span id="line-776"></span><span class="hs-comment">-- the pointer tag first, and when it is MAX_PTR_TAG, fetch the precise</span><span>
</span><span id="line-777"></span><span class="hs-comment">-- tag from the info table, and switch on that. The only technically</span><span>
</span><span id="line-778"></span><span class="hs-comment">-- tricky part is that the default case needs (logical) duplication.</span><span>
</span><span id="line-779"></span><span class="hs-comment">-- To do this we emit an extra label for it and branch to that from</span><span>
</span><span id="line-780"></span><span class="hs-comment">-- the second switch. This avoids duplicated codegen. See Trac #14373.</span><span>
</span><span id="line-781"></span><span class="hs-comment">-- See note [Double switching for big families] for the mechanics</span><span>
</span><span id="line-782"></span><span class="hs-comment">-- involved.</span><span>
</span><span id="line-783"></span><span class="hs-comment">--</span><span>
</span><span id="line-784"></span><span class="hs-comment">-- Also see note [Data constructor dynamic tags]</span><span>
</span><span id="line-785"></span><span class="hs-comment">-- and the wiki https://gitlab.haskell.org/ghc/ghc/wikis/commentary/rts/haskell-execution/pointer-tagging</span><span>
</span><span id="line-786"></span><span class="hs-comment">--</span><span>
</span><span id="line-787"></span><span>
</span><span id="line-788"></span><span class="hs-comment">-------------------</span><span>
</span><span id="line-789"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgAlgAltRhss"><span class="hs-identifier hs-type">cgAlgAltRhss</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.StgToCmm.Expr.html#GcPlan"><span class="hs-identifier hs-type">GcPlan</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.StgToCmm.Monad.html#ReturnKind"><span class="hs-identifier hs-type">ReturnKind</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Closure.html#NonVoid"><span class="hs-identifier hs-type">NonVoid</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#CgStgAlt"><span class="hs-identifier hs-type">CgStgAlt</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-790"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Graph.html#CmmAGraphScoped"><span class="hs-identifier hs-type">CmmAGraphScoped</span></a></span><span>
</span><span id="line-791"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Basic.html#ConTagZ"><span class="hs-identifier hs-type">ConTagZ</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Graph.html#CmmAGraphScoped"><span class="hs-identifier hs-type">CmmAGraphScoped</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-792"></span><span id="cgAlgAltRhss"><span class="annot"><span class="annottext">cgAlgAltRhss :: (GcPlan, ReturnKind)
-&gt; NonVoid Id
-&gt; [GenStgAlt 'CodeGen]
-&gt; FCode (Maybe CmmAGraphScoped, [(RepArity, CmmAGraphScoped)])
</span><a href="GHC.StgToCmm.Expr.html#cgAlgAltRhss"><span class="hs-identifier hs-var hs-var">cgAlgAltRhss</span></a></span></span><span> </span><span id="local-6989586621681061793"><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
</span><a href="#local-6989586621681061793"><span class="hs-identifier hs-var">gc_plan</span></a></span></span><span> </span><span id="local-6989586621681061792"><span class="annot"><span class="annottext">NonVoid Id
</span><a href="#local-6989586621681061792"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621681061791"><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061791"><span class="hs-identifier hs-var">alts</span></a></span></span><span>
</span><span id="line-793"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681061790"><span class="annot"><span class="annottext">[(AltCon, CmmAGraphScoped)]
</span><a href="#local-6989586621681061790"><span class="hs-identifier hs-var">tagged_cmms</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
-&gt; NonVoid Id
-&gt; [GenStgAlt 'CodeGen]
-&gt; FCode [(AltCon, CmmAGraphScoped)]
</span><a href="GHC.StgToCmm.Expr.html#cgAltRhss"><span class="hs-identifier hs-var">cgAltRhss</span></a></span><span> </span><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
</span><a href="#local-6989586621681061793"><span class="hs-identifier hs-var">gc_plan</span></a></span><span> </span><span class="annot"><span class="annottext">NonVoid Id
</span><a href="#local-6989586621681061792"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061791"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-794"></span><span>
</span><span id="line-795"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681061789"><span class="annot"><span class="annottext">mb_deflt :: Maybe CmmAGraphScoped
</span><a href="#local-6989586621681061789"><span class="hs-identifier hs-var hs-var">mb_deflt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[(AltCon, CmmAGraphScoped)]
</span><a href="#local-6989586621681061790"><span class="hs-identifier hs-var">tagged_cmms</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-796"></span><span>                           </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><a href="GHC.Core.html#DEFAULT"><span class="hs-identifier hs-var">DEFAULT</span></a></span><span class="hs-special">,</span><span id="local-6989586621681061788"><span class="annot"><span class="annottext">CmmAGraphScoped
</span><a href="#local-6989586621681061788"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span class="annot"><span class="annottext">[(AltCon, CmmAGraphScoped)]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CmmAGraphScoped -&gt; Maybe CmmAGraphScoped
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraphScoped
</span><a href="#local-6989586621681061788"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-797"></span><span>                           </span><span id="local-6989586621681061787"><span class="annot"><span class="annottext">[(AltCon, CmmAGraphScoped)]
</span><a href="#local-6989586621681061787"><span class="hs-identifier hs-var">_other</span></a></span></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe CmmAGraphScoped
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-798"></span><span>                            </span><span class="hs-comment">-- DEFAULT is always first, if present</span><span>
</span><span id="line-799"></span><span>
</span><span id="line-800"></span><span>              </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061786"><span class="annot"><span class="annottext">branches :: [(RepArity, CmmAGraphScoped)]
</span><a href="#local-6989586621681061786"><span class="hs-identifier hs-var hs-var">branches</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; RepArity
</span><a href="GHC.Core.DataCon.html#dataConTagZ"><span class="hs-identifier hs-var">dataConTagZ</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681061784"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmAGraphScoped
</span><a href="#local-6989586621681061783"><span class="hs-identifier hs-var">cmm</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-801"></span><span>                           </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#DataAlt"><span class="hs-identifier hs-type">DataAlt</span></a></span><span> </span><span id="local-6989586621681061784"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681061784"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681061783"><span class="annot"><span class="annottext">CmmAGraphScoped
</span><a href="#local-6989586621681061783"><span class="hs-identifier hs-var">cmm</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(AltCon, CmmAGraphScoped)]
</span><a href="#local-6989586621681061790"><span class="hs-identifier hs-var">tagged_cmms</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-802"></span><span>              </span><span class="hs-special">}</span><span>
</span><span id="line-803"></span><span>
</span><span id="line-804"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Maybe CmmAGraphScoped, [(RepArity, CmmAGraphScoped)])
-&gt; FCode (Maybe CmmAGraphScoped, [(RepArity, CmmAGraphScoped)])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe CmmAGraphScoped
</span><a href="#local-6989586621681061789"><span class="hs-identifier hs-var">mb_deflt</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(RepArity, CmmAGraphScoped)]
</span><a href="#local-6989586621681061786"><span class="hs-identifier hs-var">branches</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-805"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-806"></span><span>
</span><span id="line-807"></span><span>
</span><span id="line-808"></span><span class="hs-comment">-------------------</span><span>
</span><span id="line-809"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgAltRhss"><span class="hs-identifier hs-type">cgAltRhss</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.StgToCmm.Expr.html#GcPlan"><span class="hs-identifier hs-type">GcPlan</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.StgToCmm.Monad.html#ReturnKind"><span class="hs-identifier hs-type">ReturnKind</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Closure.html#NonVoid"><span class="hs-identifier hs-type">NonVoid</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#CgStgAlt"><span class="hs-identifier hs-type">CgStgAlt</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-810"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#AltCon"><span class="hs-identifier hs-type">AltCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Graph.html#CmmAGraphScoped"><span class="hs-identifier hs-type">CmmAGraphScoped</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-811"></span><span id="cgAltRhss"><span class="annot"><span class="annottext">cgAltRhss :: (GcPlan, ReturnKind)
-&gt; NonVoid Id
-&gt; [GenStgAlt 'CodeGen]
-&gt; FCode [(AltCon, CmmAGraphScoped)]
</span><a href="GHC.StgToCmm.Expr.html#cgAltRhss"><span class="hs-identifier hs-var hs-var">cgAltRhss</span></a></span></span><span> </span><span id="local-6989586621681061781"><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
</span><a href="#local-6989586621681061781"><span class="hs-identifier hs-var">gc_plan</span></a></span></span><span> </span><span id="local-6989586621681061780"><span class="annot"><span class="annottext">NonVoid Id
</span><a href="#local-6989586621681061780"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621681061779"><span class="annot"><span class="annottext">[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061779"><span class="hs-identifier hs-var">alts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-812"></span><span>  </span><span id="local-6989586621681061778"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061778"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-813"></span><span>  </span><span class="hs-keyword">let</span><span>
</span><span id="line-814"></span><span>    </span><span id="local-6989586621681061777"><span class="annot"><span class="annottext">base_reg :: LocalReg
</span><a href="#local-6989586621681061777"><span class="hs-identifier hs-var hs-var">base_reg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; NonVoid Id -&gt; LocalReg
</span><a href="GHC.StgToCmm.Env.html#idToReg"><span class="hs-identifier hs-var">idToReg</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061778"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">NonVoid Id
</span><a href="#local-6989586621681061780"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-815"></span><span>    </span><span class="annot"><a href="#local-6989586621681061776"><span class="hs-identifier hs-type">cg_alt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#CgStgAlt"><span class="hs-identifier hs-type">CgStgAlt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#AltCon"><span class="hs-identifier hs-type">AltCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Graph.html#CmmAGraphScoped"><span class="hs-identifier hs-type">CmmAGraphScoped</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-816"></span><span>    </span><span id="local-6989586621681061776"><span class="annot"><span class="annottext">cg_alt :: GenStgAlt 'CodeGen -&gt; FCode (AltCon, CmmAGraphScoped)
</span><a href="#local-6989586621681061776"><span class="hs-identifier hs-var hs-var">cg_alt</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681061775"><span class="annot"><span class="annottext">AltCon
</span><a href="#local-6989586621681061775"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681061774"><span class="annot"><span class="annottext">[BinderP 'CodeGen]
</span><a href="#local-6989586621681061774"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681061773"><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681061773"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-817"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FCode AltCon -&gt; FCode (AltCon, CmmAGraphScoped)
forall a. FCode a -&gt; FCode (a, CmmAGraphScoped)
</span><a href="GHC.StgToCmm.Monad.html#getCodeScoped"><span class="hs-identifier hs-var">getCodeScoped</span></a></span><span>             </span><span class="annot"><span class="annottext">(FCode AltCon -&gt; FCode (AltCon, CmmAGraphScoped))
-&gt; FCode AltCon -&gt; FCode (AltCon, CmmAGraphScoped)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-818"></span><span>        </span><span class="annot"><span class="annottext">(GcPlan, ReturnKind) -&gt; FCode AltCon -&gt; FCode AltCon
forall a. (GcPlan, ReturnKind) -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Expr.html#maybeAltHeapCheck"><span class="hs-identifier hs-var">maybeAltHeapCheck</span></a></span><span> </span><span class="annot"><span class="annottext">(GcPlan, ReturnKind)
</span><a href="#local-6989586621681061781"><span class="hs-identifier hs-var">gc_plan</span></a></span><span> </span><span class="annot"><span class="annottext">(FCode AltCon -&gt; FCode AltCon) -&gt; FCode AltCon -&gt; FCode AltCon
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-819"></span><span>        </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">AltCon -&gt; LocalReg -&gt; [NonVoid Id] -&gt; FCode [LocalReg]
</span><a href="GHC.StgToCmm.DataCon.html#bindConArgs"><span class="hs-identifier hs-var">bindConArgs</span></a></span><span> </span><span class="annot"><span class="annottext">AltCon
</span><a href="#local-6989586621681061775"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681061777"><span class="hs-identifier hs-var">base_reg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; [NonVoid Id]
</span><a href="GHC.StgToCmm.Closure.html#assertNonVoidIds"><span class="hs-identifier hs-var">assertNonVoidIds</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
[BinderP 'CodeGen]
</span><a href="#local-6989586621681061774"><span class="hs-identifier hs-var">bndrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-820"></span><span>                    </span><span class="hs-comment">-- alt binders are always non-void,</span><span>
</span><span id="line-821"></span><span>                    </span><span class="hs-comment">-- see Note [Post-unarisation invariants] in GHC.Stg.Unarise</span><span>
</span><span id="line-822"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">ReturnKind
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CgStgExpr -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgExpr"><span class="hs-identifier hs-var">cgExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CgStgExpr
</span><a href="#local-6989586621681061773"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-823"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">AltCon -&gt; FCode AltCon
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">AltCon
</span><a href="#local-6989586621681061775"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-824"></span><span>  </span><span class="annot"><span class="annottext">[FCode (AltCon, CmmAGraphScoped)]
-&gt; FCode [(AltCon, CmmAGraphScoped)]
forall a. [FCode a] -&gt; FCode [a]
</span><a href="GHC.StgToCmm.Monad.html#forkAlts"><span class="hs-identifier hs-var">forkAlts</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((AltCon, [Id], CgStgExpr) -&gt; FCode (AltCon, CmmAGraphScoped))
-&gt; [(AltCon, [Id], CgStgExpr)] -&gt; [FCode (AltCon, CmmAGraphScoped)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(AltCon, [Id], CgStgExpr) -&gt; FCode (AltCon, CmmAGraphScoped)
GenStgAlt 'CodeGen -&gt; FCode (AltCon, CmmAGraphScoped)
</span><a href="#local-6989586621681061776"><span class="hs-identifier hs-var">cg_alt</span></a></span><span> </span><span class="annot"><span class="annottext">[(AltCon, [Id], CgStgExpr)]
[GenStgAlt 'CodeGen]
</span><a href="#local-6989586621681061779"><span class="hs-identifier hs-var">alts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-825"></span><span>
</span><span id="line-826"></span><span id="local-6989586621681062349"><span class="annot"><a href="GHC.StgToCmm.Expr.html#maybeAltHeapCheck"><span class="hs-identifier hs-type">maybeAltHeapCheck</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.StgToCmm.Expr.html#GcPlan"><span class="hs-identifier hs-type">GcPlan</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.StgToCmm.Monad.html#ReturnKind"><span class="hs-identifier hs-type">ReturnKind</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681062349"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681062349"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-827"></span><span id="maybeAltHeapCheck"><span class="annot"><span class="annottext">maybeAltHeapCheck :: forall a. (GcPlan, ReturnKind) -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Expr.html#maybeAltHeapCheck"><span class="hs-identifier hs-var hs-var">maybeAltHeapCheck</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GcPlan
</span><a href="GHC.StgToCmm.Expr.html#NoGcInAlts"><span class="hs-identifier hs-var">NoGcInAlts</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">ReturnKind
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>  </span><span id="local-6989586621681061770"><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681061770"><span class="hs-identifier hs-var">code</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681061770"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-828"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#maybeAltHeapCheck"><span class="hs-identifier hs-var">maybeAltHeapCheck</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.StgToCmm.Expr.html#GcInAlts"><span class="hs-identifier hs-type">GcInAlts</span></a></span><span> </span><span id="local-6989586621681061769"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681061769"><span class="hs-identifier hs-var">regs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ReturnKind
</span><a href="GHC.StgToCmm.Monad.html#AssignedDirectly"><span class="hs-identifier hs-var">AssignedDirectly</span></a></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681061768"><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681061768"><span class="hs-identifier hs-var">code</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-829"></span><span>  </span><span class="annot"><span class="annottext">[LocalReg] -&gt; FCode a -&gt; FCode a
forall a. [LocalReg] -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#altHeapCheck"><span class="hs-identifier hs-var">altHeapCheck</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681061769"><span class="hs-identifier hs-var">regs</span></a></span><span> </span><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681061768"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-830"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#maybeAltHeapCheck"><span class="hs-identifier hs-var">maybeAltHeapCheck</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.StgToCmm.Expr.html#GcInAlts"><span class="hs-identifier hs-type">GcInAlts</span></a></span><span> </span><span id="local-6989586621681061766"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681061766"><span class="hs-identifier hs-var">regs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#ReturnedTo"><span class="hs-identifier hs-type">ReturnedTo</span></a></span><span> </span><span id="local-6989586621681061764"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061764"><span class="hs-identifier hs-var">lret</span></a></span></span><span> </span><span id="local-6989586621681061763"><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061763"><span class="hs-identifier hs-var">off</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681061762"><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681061762"><span class="hs-identifier hs-var">code</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-831"></span><span>  </span><span class="annot"><span class="annottext">[LocalReg] -&gt; BlockId -&gt; RepArity -&gt; FCode a -&gt; FCode a
forall a. [LocalReg] -&gt; BlockId -&gt; RepArity -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#altHeapCheckReturnsTo"><span class="hs-identifier hs-var">altHeapCheckReturnsTo</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681061766"><span class="hs-identifier hs-var">regs</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061764"><span class="hs-identifier hs-var">lret</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061763"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681061762"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-832"></span><span>
</span><span id="line-833"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-834"></span><span class="hs-comment">--      Tail calls</span><span>
</span><span id="line-835"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-836"></span><span>
</span><span id="line-837"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgConApp"><span class="hs-identifier hs-type">cgConApp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgArg"><span class="hs-identifier hs-type">StgArg</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#ReturnKind"><span class="hs-identifier hs-type">ReturnKind</span></a></span><span>
</span><span id="line-838"></span><span id="cgConApp"><span class="annot"><span class="annottext">cgConApp :: DataCon -&gt; [StgArg] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgConApp"><span class="hs-identifier hs-var hs-var">cgConApp</span></a></span></span><span> </span><span id="local-6989586621681061760"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681061760"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span id="local-6989586621681061759"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061759"><span class="hs-identifier hs-var">stg_args</span></a></span></span><span>
</span><span id="line-839"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; Bool
</span><a href="GHC.Core.DataCon.html#isUnboxedTupleCon"><span class="hs-identifier hs-var">isUnboxedTupleCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681061760"><span class="hs-identifier hs-var">con</span></a></span><span>       </span><span class="hs-comment">-- Unboxed tuple: assign and return</span><span>
</span><span id="line-840"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681061757"><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681061757"><span class="hs-identifier hs-var">arg_exprs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[StgArg] -&gt; FCode [CmmExpr]
</span><a href="GHC.StgToCmm.Env.html#getNonVoidArgAmodes"><span class="hs-identifier hs-var">getNonVoidArgAmodes</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061759"><span class="hs-identifier hs-var">stg_args</span></a></span><span>
</span><span id="line-841"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">RepArity -&gt; FCode ()
</span><a href="GHC.StgToCmm.Ticky.html#tickyUnboxedTupleReturn"><span class="hs-identifier hs-var">tickyUnboxedTupleReturn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CmmExpr] -&gt; RepArity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; RepArity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681061757"><span class="hs-identifier hs-var">arg_exprs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-842"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[CmmExpr] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Layout.html#emitReturn"><span class="hs-identifier hs-var">emitReturn</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681061757"><span class="hs-identifier hs-var">arg_exprs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-843"></span><span>
</span><span id="line-844"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-comment">--  Boxed constructors; allocate and return</span><span>
</span><span id="line-845"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">stg_args</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">lengthIs</span><span class="hs-special">`</span><span> </span><span class="hs-identifier">countConRepArgs</span><span> </span><span class="hs-identifier">con</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">con</span><span> </span><span class="hs-operator">&lt;&gt;</span><span> </span><span class="hs-identifier">parens</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">ppr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">countConRepArgs</span><span> </span><span class="hs-identifier">con</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">stg_args</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-846"></span><span>    </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681061753"><span class="annot"><span class="annottext">CgIdInfo
</span><a href="#local-6989586621681061753"><span class="hs-identifier hs-var">idinfo</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681061752"><span class="annot"><span class="annottext">FCode CmmAGraph
</span><a href="#local-6989586621681061752"><span class="hs-identifier hs-var">fcode_init</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id
-&gt; Bool
-&gt; CostCentreStack
-&gt; DataCon
-&gt; [NonVoid StgArg]
-&gt; FCode (CgIdInfo, FCode CmmAGraph)
</span><a href="GHC.StgToCmm.DataCon.html#buildDynCon"><span class="hs-identifier hs-var">buildDynCon</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; Id
</span><a href="GHC.Core.DataCon.html#dataConWorkId"><span class="hs-identifier hs-var">dataConWorkId</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681061760"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-847"></span><span>                                     </span><span class="annot"><span class="annottext">CostCentreStack
</span><a href="GHC.Types.CostCentre.html#currentCCS"><span class="hs-identifier hs-var">currentCCS</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681061760"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[StgArg] -&gt; [NonVoid StgArg]
</span><a href="GHC.StgToCmm.Closure.html#assertNonVoidStgArgs"><span class="hs-identifier hs-var">assertNonVoidStgArgs</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061759"><span class="hs-identifier hs-var">stg_args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-848"></span><span>                                     </span><span class="hs-comment">-- con args are always non-void,</span><span>
</span><span id="line-849"></span><span>                                     </span><span class="hs-comment">-- see Note [Post-unarisation invariants] in GHC.Stg.Unarise</span><span>
</span><span id="line-850"></span><span>                </span><span class="hs-comment">-- The first &quot;con&quot; says that the name bound to this</span><span>
</span><span id="line-851"></span><span>                </span><span class="hs-comment">-- closure is &quot;con&quot;, which is a bit of a fudge, but</span><span>
</span><span id="line-852"></span><span>                </span><span class="hs-comment">-- it only affects profiling (hence the False)</span><span>
</span><span id="line-853"></span><span>
</span><span id="line-854"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmAGraph -&gt; FCode ()) -&gt; FCode CmmAGraph -&gt; FCode ()
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3D%3C%3C"><span class="hs-operator hs-var">=&lt;&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">FCode CmmAGraph
</span><a href="#local-6989586621681061752"><span class="hs-identifier hs-var">fcode_init</span></a></span><span>
</span><span id="line-855"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">RepArity -&gt; FCode ()
</span><a href="GHC.StgToCmm.Ticky.html#tickyReturnNewCon"><span class="hs-identifier hs-var">tickyReturnNewCon</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[StgArg] -&gt; RepArity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; RepArity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061759"><span class="hs-identifier hs-var">stg_args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-856"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[CmmExpr] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Layout.html#emitReturn"><span class="hs-identifier hs-var">emitReturn</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CgIdInfo -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Env.html#idInfoToAmode"><span class="hs-identifier hs-var">idInfoToAmode</span></a></span><span> </span><span class="annot"><span class="annottext">CgIdInfo
</span><a href="#local-6989586621681061753"><span class="hs-identifier hs-var">idinfo</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-857"></span><span>
</span><span id="line-858"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgIdApp"><span class="hs-identifier hs-type">cgIdApp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgArg"><span class="hs-identifier hs-type">StgArg</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#ReturnKind"><span class="hs-identifier hs-type">ReturnKind</span></a></span><span>
</span><span id="line-859"></span><span id="cgIdApp"><span class="annot"><span class="annottext">cgIdApp :: Id -&gt; [StgArg] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#cgIdApp"><span class="hs-identifier hs-var hs-var">cgIdApp</span></a></span></span><span> </span><span id="local-6989586621681061746"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061746"><span class="hs-identifier hs-var">fun_id</span></a></span></span><span> </span><span id="local-6989586621681061745"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061745"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-860"></span><span>    </span><span id="local-6989586621681061744"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061744"><span class="hs-identifier hs-var">dflags</span></a></span></span><span>         </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-861"></span><span>    </span><span id="local-6989586621681061743"><span class="annot"><span class="annottext">CgIdInfo
</span><a href="#local-6989586621681061743"><span class="hs-identifier hs-var">fun_info</span></a></span></span><span>       </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; FCode CgIdInfo
</span><a href="GHC.StgToCmm.Env.html#getCgIdInfo"><span class="hs-identifier hs-var">getCgIdInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061746"><span class="hs-identifier hs-var">fun_id</span></a></span><span>
</span><span id="line-862"></span><span>    </span><span id="local-6989586621681061742"><span class="annot"><span class="annottext">Maybe SelfLoopInfo
</span><a href="#local-6989586621681061742"><span class="hs-identifier hs-var">self_loop_info</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode (Maybe SelfLoopInfo)
</span><a href="GHC.StgToCmm.Monad.html#getSelfLoop"><span class="hs-identifier hs-var">getSelfLoop</span></a></span><span>
</span><span id="line-863"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681061740"><span class="annot"><span class="annottext">fun_arg :: StgArg
</span><a href="#local-6989586621681061740"><span class="hs-identifier hs-var hs-var">fun_arg</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; StgArg
</span><a href="GHC.Stg.Syntax.html#StgVarArg"><span class="hs-identifier hs-var">StgVarArg</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061746"><span class="hs-identifier hs-var">fun_id</span></a></span><span>
</span><span id="line-864"></span><span>        </span><span id="local-6989586621681061739"><span class="annot"><span class="annottext">fun_name :: Name
</span><a href="#local-6989586621681061739"><span class="hs-identifier hs-var hs-var">fun_name</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span>    </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061746"><span class="hs-identifier hs-var">fun_id</span></a></span><span>
</span><span id="line-865"></span><span>        </span><span id="local-6989586621681061738"><span class="annot"><span class="annottext">fun :: CmmExpr
</span><a href="#local-6989586621681061738"><span class="hs-identifier hs-var hs-var">fun</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CgIdInfo -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Env.html#idInfoToAmode"><span class="hs-identifier hs-var">idInfoToAmode</span></a></span><span> </span><span class="annot"><span class="annottext">CgIdInfo
</span><a href="#local-6989586621681061743"><span class="hs-identifier hs-var">fun_info</span></a></span><span>
</span><span id="line-866"></span><span>        </span><span id="local-6989586621681061737"><span class="annot"><span class="annottext">lf_info :: LambdaFormInfo
</span><a href="#local-6989586621681061737"><span class="hs-identifier hs-var hs-var">lf_info</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CgIdInfo -&gt; LambdaFormInfo
</span><a href="GHC.StgToCmm.Monad.html#cg_lf"><span class="hs-identifier hs-var hs-var">cg_lf</span></a></span><span>         </span><span class="annot"><span class="annottext">CgIdInfo
</span><a href="#local-6989586621681061743"><span class="hs-identifier hs-var">fun_info</span></a></span><span>
</span><span id="line-867"></span><span>        </span><span id="local-6989586621681061734"><span class="annot"><span class="annottext">n_args :: RepArity
</span><a href="#local-6989586621681061734"><span class="hs-identifier hs-var hs-var">n_args</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[StgArg] -&gt; RepArity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; RepArity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061745"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-868"></span><span>        </span><span id="local-6989586621681061732"><span class="annot"><span class="annottext">v_args :: RepArity
</span><a href="#local-6989586621681061732"><span class="hs-identifier hs-var hs-var">v_args</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[StgArg] -&gt; RepArity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; RepArity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">([StgArg] -&gt; RepArity) -&gt; [StgArg] -&gt; RepArity
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(StgArg -&gt; Bool) -&gt; [StgArg] -&gt; [StgArg]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Types.RepType.html#isVoidTy"><span class="hs-identifier hs-var">isVoidTy</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Bool) -&gt; (StgArg -&gt; Type) -&gt; StgArg -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">StgArg -&gt; Type
</span><a href="GHC.Stg.Syntax.html#stgArgType"><span class="hs-identifier hs-var">stgArgType</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061745"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-869"></span><span>        </span><span id="local-6989586621681061730"><span class="annot"><span class="annottext">node_points :: DynFlags -&gt; Bool
</span><a href="#local-6989586621681061730"><span class="hs-identifier hs-var hs-var">node_points</span></a></span></span><span> </span><span id="local-6989586621681061729"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061729"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; LambdaFormInfo -&gt; Bool
</span><a href="GHC.StgToCmm.Closure.html#nodeMustPointToIt"><span class="hs-identifier hs-var">nodeMustPointToIt</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061729"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">LambdaFormInfo
</span><a href="#local-6989586621681061737"><span class="hs-identifier hs-var">lf_info</span></a></span><span>
</span><span id="line-870"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Name
-&gt; Id
-&gt; LambdaFormInfo
-&gt; RepArity
-&gt; RepArity
-&gt; CgLoc
-&gt; Maybe SelfLoopInfo
-&gt; CallMethod
</span><a href="GHC.StgToCmm.Closure.html#getCallMethod"><span class="hs-identifier hs-var">getCallMethod</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061744"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681061739"><span class="hs-identifier hs-var">fun_name</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061746"><span class="hs-identifier hs-var">fun_id</span></a></span><span> </span><span class="annot"><span class="annottext">LambdaFormInfo
</span><a href="#local-6989586621681061737"><span class="hs-identifier hs-var">lf_info</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061734"><span class="hs-identifier hs-var">n_args</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061732"><span class="hs-identifier hs-var">v_args</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CgIdInfo -&gt; CgLoc
</span><a href="GHC.StgToCmm.Monad.html#cg_loc"><span class="hs-identifier hs-var hs-var">cg_loc</span></a></span><span> </span><span class="annot"><span class="annottext">CgIdInfo
</span><a href="#local-6989586621681061743"><span class="hs-identifier hs-var">fun_info</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe SelfLoopInfo
</span><a href="#local-6989586621681061742"><span class="hs-identifier hs-var">self_loop_info</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-871"></span><span>            </span><span class="hs-comment">-- A value in WHNF, so we can just return it.</span><span>
</span><span id="line-872"></span><span>        </span><span class="annot"><span class="annottext">CallMethod
</span><a href="GHC.StgToCmm.Closure.html#ReturnIt"><span class="hs-identifier hs-var">ReturnIt</span></a></span><span>
</span><span id="line-873"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Types.RepType.html#isVoidTy"><span class="hs-identifier hs-var">isVoidTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681061746"><span class="hs-identifier hs-var">fun_id</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[CmmExpr] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Layout.html#emitReturn"><span class="hs-identifier hs-var">emitReturn</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-874"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[CmmExpr] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Layout.html#emitReturn"><span class="hs-identifier hs-var">emitReturn</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681061738"><span class="hs-identifier hs-var">fun</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-875"></span><span>          </span><span class="hs-comment">-- ToDo: does ReturnIt guarantee tagged?</span><span>
</span><span id="line-876"></span><span>
</span><span id="line-877"></span><span>        </span><span class="annot"><span class="annottext">CallMethod
</span><a href="GHC.StgToCmm.Closure.html#EnterIt"><span class="hs-identifier hs-var">EnterIt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">null</span><span> </span><span class="hs-identifier">args</span><span> </span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Discarding arguments</span><span>
</span><span id="line-878"></span><span>                   </span><span class="annot"><span class="annottext">CmmExpr -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#emitEnter"><span class="hs-identifier hs-var">emitEnter</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681061738"><span class="hs-identifier hs-var">fun</span></a></span><span>
</span><span id="line-879"></span><span>
</span><span id="line-880"></span><span>        </span><span class="annot"><span class="annottext">CallMethod
</span><a href="GHC.StgToCmm.Closure.html#SlowCall"><span class="hs-identifier hs-var">SlowCall</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>      </span><span class="hs-comment">-- A slow function call via the RTS apply routines</span><span>
</span><span id="line-881"></span><span>                </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">LambdaFormInfo -&gt; [StgArg] -&gt; FCode ()
</span><a href="GHC.StgToCmm.Ticky.html#tickySlowCall"><span class="hs-identifier hs-var">tickySlowCall</span></a></span><span> </span><span class="annot"><span class="annottext">LambdaFormInfo
</span><a href="#local-6989586621681061737"><span class="hs-identifier hs-var">lf_info</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061745"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-882"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitComment"><span class="hs-identifier hs-var">emitComment</span></a></span><span> </span><span class="annot"><span class="annottext">(FastString -&gt; FCode ()) -&gt; FastString -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#mkFastString"><span class="hs-identifier hs-var">mkFastString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;slowCall&quot;</span></span><span>
</span><span id="line-883"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; [StgArg] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Layout.html#slowCall"><span class="hs-identifier hs-var">slowCall</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681061738"><span class="hs-identifier hs-var">fun</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061745"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-884"></span><span>
</span><span id="line-885"></span><span>        </span><span class="hs-comment">-- A direct function call (possibly with some left-over arguments)</span><span>
</span><span id="line-886"></span><span>        </span><span class="annot"><a href="GHC.StgToCmm.Closure.html#DirectEntry"><span class="hs-identifier hs-type">DirectEntry</span></a></span><span> </span><span id="local-6989586621681061717"><span class="annot"><span class="annottext">CLabel
</span><a href="#local-6989586621681061717"><span class="hs-identifier hs-var">lbl</span></a></span></span><span> </span><span id="local-6989586621681061716"><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061716"><span class="hs-identifier hs-var">arity</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-887"></span><span>                </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">RepArity -&gt; [StgArg] -&gt; FCode ()
</span><a href="GHC.StgToCmm.Ticky.html#tickyDirectCall"><span class="hs-identifier hs-var">tickyDirectCall</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061716"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061745"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-888"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Bool
</span><a href="#local-6989586621681061730"><span class="hs-identifier hs-var">node_points</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061744"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-889"></span><span>                     </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Convention -&gt; CLabel -&gt; RepArity -&gt; [StgArg] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Layout.html#directCall"><span class="hs-identifier hs-var">directCall</span></a></span><span> </span><span class="annot"><span class="annottext">Convention
</span><a href="GHC.Cmm.Node.html#NativeNodeCall"><span class="hs-identifier hs-var">NativeNodeCall</span></a></span><span>   </span><span class="annot"><span class="annottext">CLabel
</span><a href="#local-6989586621681061717"><span class="hs-identifier hs-var">lbl</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061716"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StgArg
</span><a href="#local-6989586621681061740"><span class="hs-identifier hs-var">fun_arg</span></a></span><span class="annot"><span class="annottext">StgArg -&gt; [StgArg] -&gt; [StgArg]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061745"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-890"></span><span>                     </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Convention -&gt; CLabel -&gt; RepArity -&gt; [StgArg] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Layout.html#directCall"><span class="hs-identifier hs-var">directCall</span></a></span><span> </span><span class="annot"><span class="annottext">Convention
</span><a href="GHC.Cmm.Node.html#NativeDirectCall"><span class="hs-identifier hs-var">NativeDirectCall</span></a></span><span> </span><span class="annot"><span class="annottext">CLabel
</span><a href="#local-6989586621681061717"><span class="hs-identifier hs-var">lbl</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061716"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061745"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-891"></span><span>
</span><span id="line-892"></span><span>        </span><span class="hs-comment">-- Let-no-escape call or self-recursive tail-call</span><span>
</span><span id="line-893"></span><span>        </span><span class="annot"><a href="GHC.StgToCmm.Closure.html#JumpToIt"><span class="hs-identifier hs-type">JumpToIt</span></a></span><span> </span><span id="local-6989586621681061710"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061710"><span class="hs-identifier hs-var">blk_id</span></a></span></span><span> </span><span id="local-6989586621681061709"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681061709"><span class="hs-identifier hs-var">lne_regs</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-894"></span><span>          </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">FCode ()
</span><a href="GHC.StgToCmm.Layout.html#adjustHpBackwards"><span class="hs-identifier hs-var">adjustHpBackwards</span></a></span><span> </span><span class="hs-comment">-- always do this before a tail-call</span><span>
</span><span id="line-895"></span><span>          </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061707"><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681061707"><span class="hs-identifier hs-var">cmm_args</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[StgArg] -&gt; FCode [CmmExpr]
</span><a href="GHC.StgToCmm.Env.html#getNonVoidArgAmodes"><span class="hs-identifier hs-var">getNonVoidArgAmodes</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681061745"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-896"></span><span>          </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[LocalReg] -&gt; [CmmExpr] -&gt; FCode ()
</span><a href="GHC.StgToCmm.Utils.html#emitMultiAssign"><span class="hs-identifier hs-var">emitMultiAssign</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681061709"><span class="hs-identifier hs-var">lne_regs</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681061707"><span class="hs-identifier hs-var">cmm_args</span></a></span><span>
</span><span id="line-897"></span><span>          </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkBranch"><span class="hs-identifier hs-var">mkBranch</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061710"><span class="hs-identifier hs-var">blk_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-898"></span><span>          </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">ReturnKind -&gt; FCode ReturnKind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ReturnKind
</span><a href="GHC.StgToCmm.Monad.html#AssignedDirectly"><span class="hs-identifier hs-var">AssignedDirectly</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-899"></span><span>
</span><span id="line-900"></span><span class="hs-comment">-- Note [Self-recursive tail calls]</span><span>
</span><span id="line-901"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-902"></span><span class="hs-comment">--</span><span>
</span><span id="line-903"></span><span class="hs-comment">-- Self-recursive tail calls can be optimized into a local jump in the same</span><span>
</span><span id="line-904"></span><span class="hs-comment">-- way as let-no-escape bindings (see Note [What is a non-escaping let] in</span><span>
</span><span id="line-905"></span><span class="hs-comment">-- &quot;GHC.CoreToStg&quot;). Consider this:</span><span>
</span><span id="line-906"></span><span class="hs-comment">--</span><span>
</span><span id="line-907"></span><span class="hs-comment">-- foo.info:</span><span>
</span><span id="line-908"></span><span class="hs-comment">--     a = R1  // calling convention</span><span>
</span><span id="line-909"></span><span class="hs-comment">--     b = R2</span><span>
</span><span id="line-910"></span><span class="hs-comment">--     goto L1</span><span>
</span><span id="line-911"></span><span class="hs-comment">-- L1: ...</span><span>
</span><span id="line-912"></span><span class="hs-comment">--     ...</span><span>
</span><span id="line-913"></span><span class="hs-comment">-- ...</span><span>
</span><span id="line-914"></span><span class="hs-comment">-- L2: R1 = x</span><span>
</span><span id="line-915"></span><span class="hs-comment">--     R2 = y</span><span>
</span><span id="line-916"></span><span class="hs-comment">--     call foo(R1,R2)</span><span>
</span><span id="line-917"></span><span class="hs-comment">--</span><span>
</span><span id="line-918"></span><span class="hs-comment">-- Instead of putting x and y into registers (or other locations required by the</span><span>
</span><span id="line-919"></span><span class="hs-comment">-- calling convention) and performing a call we can put them into local</span><span>
</span><span id="line-920"></span><span class="hs-comment">-- variables a and b and perform jump to L1:</span><span>
</span><span id="line-921"></span><span class="hs-comment">--</span><span>
</span><span id="line-922"></span><span class="hs-comment">-- foo.info:</span><span>
</span><span id="line-923"></span><span class="hs-comment">--     a = R1</span><span>
</span><span id="line-924"></span><span class="hs-comment">--     b = R2</span><span>
</span><span id="line-925"></span><span class="hs-comment">--     goto L1</span><span>
</span><span id="line-926"></span><span class="hs-comment">-- L1: ...</span><span>
</span><span id="line-927"></span><span class="hs-comment">--     ...</span><span>
</span><span id="line-928"></span><span class="hs-comment">-- ...</span><span>
</span><span id="line-929"></span><span class="hs-comment">-- L2: a = x</span><span>
</span><span id="line-930"></span><span class="hs-comment">--     b = y</span><span>
</span><span id="line-931"></span><span class="hs-comment">--     goto L1</span><span>
</span><span id="line-932"></span><span class="hs-comment">--</span><span>
</span><span id="line-933"></span><span class="hs-comment">-- This can be done only when function is calling itself in a tail position</span><span>
</span><span id="line-934"></span><span class="hs-comment">-- and only if the call passes number of parameters equal to function's arity.</span><span>
</span><span id="line-935"></span><span class="hs-comment">-- Note that this cannot be performed if a function calls itself with a</span><span>
</span><span id="line-936"></span><span class="hs-comment">-- continuation.</span><span>
</span><span id="line-937"></span><span class="hs-comment">--</span><span>
</span><span id="line-938"></span><span class="hs-comment">-- This in fact implements optimization known as &quot;loopification&quot;. It was</span><span>
</span><span id="line-939"></span><span class="hs-comment">-- described in &quot;Low-level code optimizations in the Glasgow Haskell Compiler&quot;</span><span>
</span><span id="line-940"></span><span class="hs-comment">-- by Krzysztof Wo&#347;, though we use different approach. Krzysztof performed his</span><span>
</span><span id="line-941"></span><span class="hs-comment">-- optimization at the Cmm level, whereas we perform ours during code generation</span><span>
</span><span id="line-942"></span><span class="hs-comment">-- (Stg-to-Cmm pass) essentially making sure that optimized Cmm code is</span><span>
</span><span id="line-943"></span><span class="hs-comment">-- generated in the first place.</span><span>
</span><span id="line-944"></span><span class="hs-comment">--</span><span>
</span><span id="line-945"></span><span class="hs-comment">-- Implementation is spread across a couple of places in the code:</span><span>
</span><span id="line-946"></span><span class="hs-comment">--</span><span>
</span><span id="line-947"></span><span class="hs-comment">--   * FCode monad stores additional information in its reader environment</span><span>
</span><span id="line-948"></span><span class="hs-comment">--     (cgd_self_loop field). This information tells us which function can</span><span>
</span><span id="line-949"></span><span class="hs-comment">--     tail call itself in an optimized way (it is the function currently</span><span>
</span><span id="line-950"></span><span class="hs-comment">--     being compiled), what is the label of a loop header (L1 in example above)</span><span>
</span><span id="line-951"></span><span class="hs-comment">--     and information about local registers in which we should arguments</span><span>
</span><span id="line-952"></span><span class="hs-comment">--     before making a call (this would be a and b in example above).</span><span>
</span><span id="line-953"></span><span class="hs-comment">--</span><span>
</span><span id="line-954"></span><span class="hs-comment">--   * Whenever we are compiling a function, we set that information to reflect</span><span>
</span><span id="line-955"></span><span class="hs-comment">--     the fact that function currently being compiled can be jumped to, instead</span><span>
</span><span id="line-956"></span><span class="hs-comment">--     of called. This is done in closureCodyBody in GHC.StgToCmm.Bind.</span><span>
</span><span id="line-957"></span><span class="hs-comment">--</span><span>
</span><span id="line-958"></span><span class="hs-comment">--   * We also have to emit a label to which we will be jumping. We make sure</span><span>
</span><span id="line-959"></span><span class="hs-comment">--     that the label is placed after a stack check but before the heap</span><span>
</span><span id="line-960"></span><span class="hs-comment">--     check. The reason is that making a recursive tail-call does not increase</span><span>
</span><span id="line-961"></span><span class="hs-comment">--     the stack so we only need to check once. But it may grow the heap, so we</span><span>
</span><span id="line-962"></span><span class="hs-comment">--     have to repeat the heap check in every self-call. This is done in</span><span>
</span><span id="line-963"></span><span class="hs-comment">--     do_checks in GHC.StgToCmm.Heap.</span><span>
</span><span id="line-964"></span><span class="hs-comment">--</span><span>
</span><span id="line-965"></span><span class="hs-comment">--   * When we begin compilation of another closure we remove the additional</span><span>
</span><span id="line-966"></span><span class="hs-comment">--     information from the environment. This is done by forkClosureBody</span><span>
</span><span id="line-967"></span><span class="hs-comment">--     in GHC.StgToCmm.Monad. Other functions that duplicate the environment -</span><span>
</span><span id="line-968"></span><span class="hs-comment">--     forkLneBody, forkAlts, codeOnly - duplicate that information. In other</span><span>
</span><span id="line-969"></span><span class="hs-comment">--     words, we only need to clean the environment of the self-loop information</span><span>
</span><span id="line-970"></span><span class="hs-comment">--     when compiling right hand side of a closure (binding).</span><span>
</span><span id="line-971"></span><span class="hs-comment">--</span><span>
</span><span id="line-972"></span><span class="hs-comment">--   * When compiling a call (cgIdApp) we use getCallMethod to decide what kind</span><span>
</span><span id="line-973"></span><span class="hs-comment">--     of call will be generated. getCallMethod decides to generate a self</span><span>
</span><span id="line-974"></span><span class="hs-comment">--     recursive tail call when (a) environment stores information about</span><span>
</span><span id="line-975"></span><span class="hs-comment">--     possible self tail-call; (b) that tail call is to a function currently</span><span>
</span><span id="line-976"></span><span class="hs-comment">--     being compiled; (c) number of passed non-void arguments is equal to</span><span>
</span><span id="line-977"></span><span class="hs-comment">--     function's arity. (d) loopification is turned on via -floopification</span><span>
</span><span id="line-978"></span><span class="hs-comment">--     command-line option.</span><span>
</span><span id="line-979"></span><span class="hs-comment">--</span><span>
</span><span id="line-980"></span><span class="hs-comment">--   * Command line option to turn loopification on and off is implemented in</span><span>
</span><span id="line-981"></span><span class="hs-comment">--     DynFlags.</span><span>
</span><span id="line-982"></span><span class="hs-comment">--</span><span>
</span><span id="line-983"></span><span class="hs-comment">--</span><span>
</span><span id="line-984"></span><span class="hs-comment">-- Note [Void arguments in self-recursive tail calls]</span><span>
</span><span id="line-985"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-986"></span><span class="hs-comment">--</span><span>
</span><span id="line-987"></span><span class="hs-comment">-- State# tokens can get in the way of the loopification optimization as seen in</span><span>
</span><span id="line-988"></span><span class="hs-comment">-- #11372. Consider this:</span><span>
</span><span id="line-989"></span><span class="hs-comment">--</span><span>
</span><span id="line-990"></span><span class="hs-comment">-- foo :: [a]</span><span>
</span><span id="line-991"></span><span class="hs-comment">--     -&gt; (a -&gt; State# s -&gt; (# State s, Bool #))</span><span>
</span><span id="line-992"></span><span class="hs-comment">--     -&gt; State# s</span><span>
</span><span id="line-993"></span><span class="hs-comment">--     -&gt; (# State# s, Maybe a #)</span><span>
</span><span id="line-994"></span><span class="hs-comment">-- foo [] f s = (# s, Nothing #)</span><span>
</span><span id="line-995"></span><span class="hs-comment">-- foo (x:xs) f s = case f x s of</span><span>
</span><span id="line-996"></span><span class="hs-comment">--      (# s', b #) -&gt; case b of</span><span>
</span><span id="line-997"></span><span class="hs-comment">--          True -&gt; (# s', Just x #)</span><span>
</span><span id="line-998"></span><span class="hs-comment">--          False -&gt; foo xs f s'</span><span>
</span><span id="line-999"></span><span class="hs-comment">--</span><span>
</span><span id="line-1000"></span><span class="hs-comment">-- We would like to compile the call to foo as a local jump instead of a call</span><span>
</span><span id="line-1001"></span><span class="hs-comment">-- (see Note [Self-recursive tail calls]). However, the generated function has</span><span>
</span><span id="line-1002"></span><span class="hs-comment">-- an arity of 2 while we apply it to 3 arguments, one of them being of void</span><span>
</span><span id="line-1003"></span><span class="hs-comment">-- type. Thus, we mustn't count arguments of void type when checking whether</span><span>
</span><span id="line-1004"></span><span class="hs-comment">-- we can turn a call into a self-recursive jump.</span><span>
</span><span id="line-1005"></span><span class="hs-comment">--</span><span>
</span><span id="line-1006"></span><span>
</span><span id="line-1007"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#emitEnter"><span class="hs-identifier hs-type">emitEnter</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#ReturnKind"><span class="hs-identifier hs-type">ReturnKind</span></a></span><span>
</span><span id="line-1008"></span><span id="emitEnter"><span class="annot"><span class="annottext">emitEnter :: CmmExpr -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Expr.html#emitEnter"><span class="hs-identifier hs-var hs-var">emitEnter</span></a></span></span><span> </span><span id="local-6989586621681061705"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681061705"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1009"></span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681061704"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061704"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-1010"></span><span>  </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061703"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061703"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-1011"></span><span>  </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">FCode ()
</span><a href="GHC.StgToCmm.Layout.html#adjustHpBackwards"><span class="hs-identifier hs-var">adjustHpBackwards</span></a></span><span>
</span><span id="line-1012"></span><span>  </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061702"><span class="annot"><span class="annottext">Sequel
</span><a href="#local-6989586621681061702"><span class="hs-identifier hs-var">sequel</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Sequel
</span><a href="GHC.StgToCmm.Monad.html#getSequel"><span class="hs-identifier hs-var">getSequel</span></a></span><span>
</span><span id="line-1013"></span><span>  </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061700"><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061700"><span class="hs-identifier hs-var">updfr_off</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode RepArity
</span><a href="GHC.StgToCmm.Monad.html#getUpdFrameOff"><span class="hs-identifier hs-var">getUpdFrameOff</span></a></span><span>
</span><span id="line-1014"></span><span>  </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Sequel
</span><a href="#local-6989586621681061702"><span class="hs-identifier hs-var">sequel</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1015"></span><span>      </span><span class="hs-comment">-- For a return, we have the option of generating a tag-test or</span><span>
</span><span id="line-1016"></span><span>      </span><span class="hs-comment">-- not.  If the value is tagged, we can return directly, which</span><span>
</span><span id="line-1017"></span><span>      </span><span class="hs-comment">-- is quicker than entering the value.  This is a code</span><span>
</span><span id="line-1018"></span><span>      </span><span class="hs-comment">-- size/speed trade-off: when optimising for speed rather than</span><span>
</span><span id="line-1019"></span><span>      </span><span class="hs-comment">-- size we could generate the tag test.</span><span>
</span><span id="line-1020"></span><span>      </span><span class="hs-comment">--</span><span>
</span><span id="line-1021"></span><span>      </span><span class="hs-comment">-- Right now, we do what the old codegen did, and omit the tag</span><span>
</span><span id="line-1022"></span><span>      </span><span class="hs-comment">-- test, just generating an enter.</span><span>
</span><span id="line-1023"></span><span>      </span><span class="annot"><span class="annottext">Sequel
</span><a href="GHC.StgToCmm.Monad.html#Return"><span class="hs-identifier hs-var">Return</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1024"></span><span>        </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681061697"><span class="annot"><span class="annottext">entry :: CmmExpr
</span><a href="#local-6989586621681061697"><span class="hs-identifier hs-var hs-var">entry</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.Cmm.Info.html#entryCode"><span class="hs-identifier hs-var">entryCode</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061703"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmExpr -&gt; CmmExpr) -&gt; CmmExpr -&gt; CmmExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.Cmm.Info.html#closureInfoPtr"><span class="hs-identifier hs-var">closureInfoPtr</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061704"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmExpr -&gt; CmmExpr) -&gt; CmmExpr -&gt; CmmExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="GHC.Cmm.Expr.html#nodeReg"><span class="hs-identifier hs-var">nodeReg</span></a></span><span>
</span><span id="line-1025"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmAGraph -&gt; FCode ()) -&gt; CmmAGraph -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Convention -&gt; CmmExpr -&gt; [CmmExpr] -&gt; RepArity -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkJump"><span class="hs-identifier hs-var">mkJump</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061704"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Convention
</span><a href="GHC.Cmm.Node.html#NativeNodeCall"><span class="hs-identifier hs-var">NativeNodeCall</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681061697"><span class="hs-identifier hs-var">entry</span></a></span><span>
</span><span id="line-1026"></span><span>                        </span><span class="hs-special">[</span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmUntag"><span class="hs-identifier hs-var">cmmUntag</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061704"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681061705"><span class="hs-identifier hs-var">fun</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061700"><span class="hs-identifier hs-var">updfr_off</span></a></span><span>
</span><span id="line-1027"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">ReturnKind -&gt; FCode ReturnKind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ReturnKind
</span><a href="GHC.StgToCmm.Monad.html#AssignedDirectly"><span class="hs-identifier hs-var">AssignedDirectly</span></a></span><span>
</span><span id="line-1028"></span><span>        </span><span class="hs-special">}</span><span>
</span><span id="line-1029"></span><span>
</span><span id="line-1030"></span><span>      </span><span class="hs-comment">-- The result will be scrutinised in the sequel.  This is where</span><span>
</span><span id="line-1031"></span><span>      </span><span class="hs-comment">-- we generate a tag-test to avoid entering the closure if</span><span>
</span><span id="line-1032"></span><span>      </span><span class="hs-comment">-- possible.</span><span>
</span><span id="line-1033"></span><span>      </span><span class="hs-comment">--</span><span>
</span><span id="line-1034"></span><span>      </span><span class="hs-comment">-- The generated code will be something like this:</span><span>
</span><span id="line-1035"></span><span>      </span><span class="hs-comment">--</span><span>
</span><span id="line-1036"></span><span>      </span><span class="hs-comment">--    R1 = fun  -- copyout</span><span>
</span><span id="line-1037"></span><span>      </span><span class="hs-comment">--    if (fun &amp; 7 != 0) goto Lret else goto Lcall</span><span>
</span><span id="line-1038"></span><span>      </span><span class="hs-comment">--  Lcall:</span><span>
</span><span id="line-1039"></span><span>      </span><span class="hs-comment">--    call [fun] returns to Lret</span><span>
</span><span id="line-1040"></span><span>      </span><span class="hs-comment">--  Lret:</span><span>
</span><span id="line-1041"></span><span>      </span><span class="hs-comment">--    fun' = R1  -- copyin</span><span>
</span><span id="line-1042"></span><span>      </span><span class="hs-comment">--    ...</span><span>
</span><span id="line-1043"></span><span>      </span><span class="hs-comment">--</span><span>
</span><span id="line-1044"></span><span>      </span><span class="hs-comment">-- Note in particular that the label Lret is used as a</span><span>
</span><span id="line-1045"></span><span>      </span><span class="hs-comment">-- destination by both the tag-test and the call.  This is</span><span>
</span><span id="line-1046"></span><span>      </span><span class="hs-comment">-- because Lret will necessarily be a proc-point, and we want to</span><span>
</span><span id="line-1047"></span><span>      </span><span class="hs-comment">-- ensure that we generate only one proc-point for this</span><span>
</span><span id="line-1048"></span><span>      </span><span class="hs-comment">-- sequence.</span><span>
</span><span id="line-1049"></span><span>      </span><span class="hs-comment">--</span><span>
</span><span id="line-1050"></span><span>      </span><span class="hs-comment">-- Furthermore, we tell the caller that we generated a native</span><span>
</span><span id="line-1051"></span><span>      </span><span class="hs-comment">-- return continuation by returning (ReturnedTo Lret off), so</span><span>
</span><span id="line-1052"></span><span>      </span><span class="hs-comment">-- that the continuation can be reused by the heap-check failure</span><span>
</span><span id="line-1053"></span><span>      </span><span class="hs-comment">-- code in the enclosing case expression.</span><span>
</span><span id="line-1054"></span><span>      </span><span class="hs-comment">--</span><span>
</span><span id="line-1055"></span><span>      </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#AssignTo"><span class="hs-identifier hs-type">AssignTo</span></a></span><span> </span><span id="local-6989586621681061692"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681061692"><span class="hs-identifier hs-var">res_regs</span></a></span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1056"></span><span>       </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681061691"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061691"><span class="hs-identifier hs-var">lret</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode BlockId
forall (m :: * -&gt; *). MonadUnique m =&gt; m BlockId
</span><a href="GHC.Cmm.BlockId.html#newBlockId"><span class="hs-identifier hs-var">newBlockId</span></a></span><span>
</span><span id="line-1057"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681061690"><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061690"><span class="hs-identifier hs-var">off</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[GlobalReg]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681061689"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681061689"><span class="hs-identifier hs-var">copyin</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Convention
-&gt; Area
-&gt; [LocalReg]
-&gt; [LocalReg]
-&gt; (RepArity, [GlobalReg], CmmAGraph)
</span><a href="GHC.Cmm.Graph.html#copyInOflow"><span class="hs-identifier hs-var">copyInOflow</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061704"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Convention
</span><a href="GHC.Cmm.Node.html#NativeReturn"><span class="hs-identifier hs-var">NativeReturn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; Area
</span><a href="GHC.Cmm.Expr.html#Young"><span class="hs-identifier hs-var">Young</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061691"><span class="hs-identifier hs-var">lret</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681061692"><span class="hs-identifier hs-var">res_regs</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1058"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061685"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061685"><span class="hs-identifier hs-var">lcall</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode BlockId
forall (m :: * -&gt; *). MonadUnique m =&gt; m BlockId
</span><a href="GHC.Cmm.BlockId.html#newBlockId"><span class="hs-identifier hs-var">newBlockId</span></a></span><span>
</span><span id="line-1059"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061684"><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061684"><span class="hs-identifier hs-var">updfr_off</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode RepArity
</span><a href="GHC.StgToCmm.Monad.html#getUpdFrameOff"><span class="hs-identifier hs-var">getUpdFrameOff</span></a></span><span>
</span><span id="line-1060"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681061683"><span class="annot"><span class="annottext">area :: Area
</span><a href="#local-6989586621681061683"><span class="hs-identifier hs-var hs-var">area</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; Area
</span><a href="GHC.Cmm.Expr.html#Young"><span class="hs-identifier hs-var">Young</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061691"><span class="hs-identifier hs-var">lret</span></a></span><span>
</span><span id="line-1061"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681061682"><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061682"><span class="hs-identifier hs-var">outArgs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681061681"><span class="annot"><span class="annottext">[GlobalReg]
</span><a href="#local-6989586621681061681"><span class="hs-identifier hs-var">regs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681061680"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681061680"><span class="hs-identifier hs-var">copyout</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Convention
-&gt; Transfer
-&gt; Area
-&gt; [CmmExpr]
-&gt; RepArity
-&gt; [CmmExpr]
-&gt; (RepArity, [GlobalReg], CmmAGraph)
</span><a href="GHC.Cmm.Graph.html#copyOutOflow"><span class="hs-identifier hs-var">copyOutOflow</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061704"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Convention
</span><a href="GHC.Cmm.Node.html#NativeNodeCall"><span class="hs-identifier hs-var">NativeNodeCall</span></a></span><span> </span><span class="annot"><span class="annottext">Transfer
</span><a href="GHC.Cmm.Graph.html#Call"><span class="hs-identifier hs-var">Call</span></a></span><span> </span><span class="annot"><span class="annottext">Area
</span><a href="#local-6989586621681061683"><span class="hs-identifier hs-var">area</span></a></span><span>
</span><span id="line-1062"></span><span>                                          </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681061705"><span class="hs-identifier hs-var">fun</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061684"><span class="hs-identifier hs-var">updfr_off</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1063"></span><span>         </span><span class="hs-comment">-- refer to fun via nodeReg after the copyout, to avoid having</span><span>
</span><span id="line-1064"></span><span>         </span><span class="hs-comment">-- both live simultaneously; this sometimes enables fun to be</span><span>
</span><span id="line-1065"></span><span>         </span><span class="hs-comment">-- inlined in the RHS of the R1 assignment.</span><span>
</span><span id="line-1066"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681061677"><span class="annot"><span class="annottext">entry :: CmmExpr
</span><a href="#local-6989586621681061677"><span class="hs-identifier hs-var hs-var">entry</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.Cmm.Info.html#entryCode"><span class="hs-identifier hs-var">entryCode</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061703"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.Cmm.Info.html#closureInfoPtr"><span class="hs-identifier hs-var">closureInfoPtr</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061704"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="GHC.Cmm.Expr.html#nodeReg"><span class="hs-identifier hs-var">nodeReg</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1067"></span><span>             </span><span id="local-6989586621681061676"><span class="annot"><span class="annottext">the_call :: CmmAGraph
</span><a href="#local-6989586621681061676"><span class="hs-identifier hs-var hs-var">the_call</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmExpr
-&gt; Maybe BlockId
-&gt; RepArity
-&gt; RepArity
-&gt; RepArity
-&gt; [GlobalReg]
-&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#toCall"><span class="hs-identifier hs-var">toCall</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681061677"><span class="hs-identifier hs-var">entry</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; Maybe BlockId
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061691"><span class="hs-identifier hs-var">lret</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061684"><span class="hs-identifier hs-var">updfr_off</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061690"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061682"><span class="hs-identifier hs-var">outArgs</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalReg]
</span><a href="#local-6989586621681061681"><span class="hs-identifier hs-var">regs</span></a></span><span>
</span><span id="line-1068"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681061674"><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681061674"><span class="hs-identifier hs-var">tscope</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode CmmTickScope
</span><a href="GHC.StgToCmm.Monad.html#getTickScope"><span class="hs-identifier hs-var">getTickScope</span></a></span><span>
</span><span id="line-1069"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmAGraph -&gt; FCode ()) -&gt; CmmAGraph -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1070"></span><span>           </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681061680"><span class="hs-identifier hs-var">copyout</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; CmmAGraph -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span>
</span><span id="line-1071"></span><span>           </span><span class="annot"><span class="annottext">CmmExpr -&gt; BlockId -&gt; BlockId -&gt; Maybe Bool -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkCbranch"><span class="hs-identifier hs-var">mkCbranch</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmIsTagged"><span class="hs-identifier hs-var">cmmIsTagged</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681061704"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="GHC.Cmm.Expr.html#nodeReg"><span class="hs-identifier hs-var">nodeReg</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1072"></span><span>                     </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061691"><span class="hs-identifier hs-var">lret</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061685"><span class="hs-identifier hs-var">lcall</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Bool
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; CmmAGraph -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span>
</span><span id="line-1073"></span><span>           </span><span class="annot"><span class="annottext">BlockId -&gt; CmmAGraphScoped -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#outOfLine"><span class="hs-identifier hs-var">outOfLine</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061685"><span class="hs-identifier hs-var">lcall</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681061676"><span class="hs-identifier hs-var">the_call</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681061674"><span class="hs-identifier hs-var">tscope</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; CmmAGraph -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span>
</span><span id="line-1074"></span><span>           </span><span class="annot"><span class="annottext">BlockId -&gt; CmmTickScope -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkLabel"><span class="hs-identifier hs-var">mkLabel</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061691"><span class="hs-identifier hs-var">lret</span></a></span><span> </span><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681061674"><span class="hs-identifier hs-var">tscope</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; CmmAGraph -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span>
</span><span id="line-1075"></span><span>           </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681061689"><span class="hs-identifier hs-var">copyin</span></a></span><span>
</span><span id="line-1076"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">ReturnKind -&gt; FCode ReturnKind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; RepArity -&gt; ReturnKind
</span><a href="GHC.StgToCmm.Monad.html#ReturnedTo"><span class="hs-identifier hs-var">ReturnedTo</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681061691"><span class="hs-identifier hs-var">lret</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061690"><span class="hs-identifier hs-var">off</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1077"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-1078"></span><span>  </span><span class="hs-special">}</span><span>
</span><span id="line-1079"></span><span>
</span><span id="line-1080"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-1081"></span><span class="hs-comment">--              Ticks</span><span>
</span><span id="line-1082"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-1083"></span><span>
</span><span id="line-1084"></span><span class="hs-comment">-- | Generate Cmm code for a tick. Depending on the type of Tickish,</span><span>
</span><span id="line-1085"></span><span class="hs-comment">-- this will either generate actual Cmm instrumentation code, or</span><span>
</span><span id="line-1086"></span><span class="hs-comment">-- simply pass on the annotation as a @CmmTickish@.</span><span>
</span><span id="line-1087"></span><span class="annot"><a href="GHC.StgToCmm.Expr.html#cgTick"><span class="hs-identifier hs-type">cgTick</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#Tickish"><span class="hs-identifier hs-type">Tickish</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1088"></span><span id="cgTick"><span class="annot"><span class="annottext">cgTick :: Tickish Id -&gt; FCode ()
</span><a href="GHC.StgToCmm.Expr.html#cgTick"><span class="hs-identifier hs-var hs-var">cgTick</span></a></span></span><span> </span><span id="local-6989586621681061670"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621681061670"><span class="hs-identifier hs-var">tick</span></a></span></span><span>
</span><span id="line-1089"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681061669"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061669"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-1090"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621681061670"><span class="hs-identifier hs-var">tick</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1091"></span><span>           </span><span class="annot"><a href="GHC.Core.html#ProfNote"><span class="hs-identifier hs-type">ProfNote</span></a></span><span>   </span><span id="local-6989586621681061667"><span class="annot"><span class="annottext">CostCentre
</span><a href="#local-6989586621681061667"><span class="hs-identifier hs-var">cc</span></a></span></span><span> </span><span id="local-6989586621681061666"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681061666"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621681061665"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681061665"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CostCentre -&gt; Bool -&gt; Bool -&gt; FCode ()
</span><a href="GHC.StgToCmm.Prof.html#emitSetCCC"><span class="hs-identifier hs-var">emitSetCCC</span></a></span><span> </span><span class="annot"><span class="annottext">CostCentre
</span><a href="#local-6989586621681061667"><span class="hs-identifier hs-var">cc</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681061666"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681061665"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-1092"></span><span>           </span><span class="annot"><a href="GHC.Core.html#HpcTick"><span class="hs-identifier hs-type">HpcTick</span></a></span><span>    </span><span id="local-6989586621681061663"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681061663"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681061662"><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061662"><span class="hs-identifier hs-var">n</span></a></span></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; Module -&gt; RepArity -&gt; CmmAGraph
</span><a href="GHC.StgToCmm.Hpc.html#mkTickBox"><span class="hs-identifier hs-var">mkTickBox</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681061669"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681061663"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">RepArity
</span><a href="#local-6989586621681061662"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1093"></span><span>           </span><span class="annot"><a href="GHC.Core.html#SourceNote"><span class="hs-identifier hs-type">SourceNote</span></a></span><span> </span><span id="local-6989586621681061659"><span class="annot"><span class="annottext">RealSrcSpan
</span><a href="#local-6989586621681061659"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span id="local-6989586621681061658"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681061658"><span class="hs-identifier hs-var">n</span></a></span></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CmmTickish -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitTick"><span class="hs-identifier hs-var">emitTick</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmTickish -&gt; FCode ()) -&gt; CmmTickish -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">RealSrcSpan -&gt; String -&gt; CmmTickish
forall id. RealSrcSpan -&gt; String -&gt; Tickish id
</span><a href="GHC.Core.html#SourceNote"><span class="hs-identifier hs-var">SourceNote</span></a></span><span> </span><span class="annot"><span class="annottext">RealSrcSpan
</span><a href="#local-6989586621681061659"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681061658"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1094"></span><span>           </span><span id="local-6989586621681061656"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621681061656"><span class="hs-identifier hs-var">_other</span></a></span></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; FCode ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- ignore</span><span>
</span><span id="line-1095"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-1096"></span></pre></body></html>